Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: compiled binaries set PT_GNU_STACK alignment to 2**3 on amd64 #12013
Apologies ahead of time if this issue is raised in the wrong spot; the golang/tools repo is only a mirror, and couldn't raise it there, where I suspect it belongs.
I was scanning all of my binaries in
$ objdump -p /usr/lib/go/pkg/tool/linux_amd64/cgo /usr/lib/go/pkg/tool/linux_amd64/cgo: file format elf64-x86-64 Program Header: PHDR off 0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**12 filesz 0x0000000000000150 memsz 0x0000000000000150 flags r-x LOAD off 0x0000000000000040 vaddr 0x0000000000400040 paddr 0x0000000000400040 align 2**12 filesz 0x0000000000122856 memsz 0x0000000000122856 flags r-x LOAD off 0x0000000000123000 vaddr 0x0000000000523000 paddr 0x0000000000523000 align 2**12 filesz 0x000000000024e959 memsz 0x000000000024e959 flags r-- LOAD off 0x0000000000372000 vaddr 0x0000000000772000 paddr 0x0000000000772000 align 2**12 filesz 0x0000000000016d00 memsz 0x0000000000034f18 flags rw- STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3 filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw- 0x65041580 off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**3 filesz 0x0000000000000000 memsz 0x0000000000000000 flags --- 2a00
If I had to guess, I'd say perhaps the 2nd to last program header, STACK, has an incorrect alignment (2³ instead of 2⁴ which you normally see in programs), and this might be bleeding over into the next program header. It's hard to say though, obviously.
I've only checked on the following linux systems:
I don't think this is specific to the cgo binary. I see this for all Go executables on my Ubuntu 14.04 amd64 machine. However, I also see it for about 20% of executables in /usr/bin.
What exactly is the consequence of this? I can't find any documented significance to the alignment field of PT_GNU_STACK. Glibc only seems to care about the flags field.
@mdempsky yea I'm not sure what alignment does
However, I'm not sure I'd have changed the title, since the issue was specifically about the last program header being bad (unless you think the alignment is the cause of the malformed final header), e.g.:
is not a valid header; not only is the program header name unknown, it's flags are nill, and it has '2a00' after flags, which is probably an artifact of