]> Cypherpunks repositories - gostls13.git/commit
cmd/link/internal/ld: fix sort comparison
authorRuss Cox <rsc@golang.org>
Wed, 30 Oct 2024 23:23:47 +0000 (19:23 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 6 Nov 2024 17:34:44 +0000 (17:34 +0000)
commit72801623cbe4cedcb3334d31fa44ff31914a26d5
tree282c0b961aa795b4f928ce48d28c307326037406
parent7fff741016c8157e107cce8013ee3ca621725384
cmd/link/internal/ld: fix sort comparison

Strictly speaking, the sort comparison was inconsistent
(and therefore invalid) for the sort-by-name case, if you had

a size 0
b size 1
c size 0
zerobase

That would result in the inconsistent comparison ordering:

a < b (by name)
b < c (by name)
c < zerobase (by zerobase rule)
zerobase < b (by zerobase rule)

This can't happen today because we only disable size-based
sort in a segment that has no zerobase symbol, but it's
confusing to reason through that, so clean up the code anyway.

Passes golang.org/x/tools/cmd/toolstash/buildall.

Change-Id: I21e4159cdedd2053952ba960530d1b0f28c6fb24
Reviewed-on: https://go-review.googlesource.com/c/go/+/625615
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/link/internal/ld/data.go