]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/objfile: align the load address of ELF binary
authorCherry Mui <cherryyz@google.com>
Fri, 7 Apr 2023 00:26:55 +0000 (20:26 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 7 Apr 2023 20:44:50 +0000 (20:44 +0000)
commit46a49eb52e6402708446a7a71db8a29dbdb99139
treed213fbb4369a59aa64175dcc224969f119959517
parent0d3c23fe87ca0ee727d833ce11ab16b405a93ea3
cmd/internal/objfile: align the load address of ELF binary

The ELF ABI just requires that the address and the offset of a
segment are congruent modulo the alignment, but does not require
the start address to be aligned. While usually the segment's
start address is aligned, apparently the zig linker generates
binary with unaligned address.

At the run time, the memory mapping that contains the segment
starts at an aligned address (rounding down). Use the aligned
address for the load address, which matches the mapping.
Apparently this is what the pprof library expects.

Fixes #59466.

Change-Id: Ife78909b20b7bc975ac4c76f2c5f5db325ddec9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/483035
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
src/cmd/internal/objfile/elf.go