Skip to content

Commit

Permalink
cmd/link: add padding after runtime.etext
Browse files Browse the repository at this point in the history
The runtime.etext symbol is a marker symbol that marks the end of
(Go's) text section. Currently it has 0 size on some platforms.
Especially in external linking mode, this may cause the next
symbol (e.g. a C function) to have the same address as
runtime.etext, which may confuse some symbolizer. Add some padding
bytes to avoid address collision.

Change-Id: Ic450bab72e4ac79a3b6b891729831d4148b89234
Reviewed-on: https://go-review.googlesource.com/c/go/+/479075
Run-TryBot: Cherry Mui <[email protected]>
Reviewed-by: Nicolas Hillegeer <[email protected]>
Run-TryBot: Nicolas Hillegeer <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
cherrymui committed Mar 24, 2023
1 parent e4abe90 commit a6c382e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cmd/link/internal/ld/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,9 @@ func (ctxt *Link) textaddress() {
}
}

sect.Length = va - sect.Vaddr
// Add MinLC size after etext, so it won't collide with the next symbol
// (which may confuse some symbolizer).
sect.Length = va - sect.Vaddr + uint64(ctxt.Arch.MinLC)
ldr.SetSymSect(etext, sect)
if ldr.SymValue(etext) == 0 {
// Set the address of the start/end symbols, if not already
Expand Down

0 comments on commit a6c382e

Please sign in to comment.