]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link: add padding after runtime.etext
authorCherry Mui <cherryyz@google.com>
Thu, 23 Mar 2023 20:10:05 +0000 (16:10 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 24 Mar 2023 14:23:19 +0000 (14:23 +0000)
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 <cherryyz@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
Run-TryBot: Nicolas Hillegeer <aktau@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/link/internal/ld/data.go

index bd8d17b11023f4576c8d7d7f179327f3dd912ac4..01f9bc7099f037fdd1703bb3b54521fce821ea2e 100644 (file)
@@ -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