Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: trailing padding after "Go" in ELF note name #36719

Open
mdempsky opened this issue Jan 24, 2020 · 7 comments
Open

cmd/link: trailing padding after "Go" in ELF note name #36719

mdempsky opened this issue Jan 24, 2020 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

https://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section says [emphasis added]:

namesz and name
The first namesz bytes in name contain a null-terminated character representation of the entry's owner or originator. There is no formal mechanism for avoiding name conflicts. By convention, vendors use their own name, such as XYZ Computer Company, as the identifier. If no name is present, namesz contains 0. Padding is present, if necessary, to ensure 8 or 4-byte alignment for the descriptor (depending on whether the file is a 64-bit or 32-bit object). Such padding is not included in namesz.

It looks like we get this right for the "NetBSD" tag, where we include a single nul-terminator character within the name (as measured by namesz), but then include an extra padding zero-byte for alignment.

However, for the "Go" tag, we include an extra nul-terminator within the name itself. The second nul-terminator should actually be padding.

Pointed out by Mark Kettenis from OpenBSD.

/cc @4a6f656c

@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 24, 2020
@mdempsky mdempsky added this to the Go1.15 milestone Jan 24, 2020
@mdempsky mdempsky changed the title cmd/link: trailing padding after "Go" in elf note cmd/link: trailing padding after "Go" in ELF note name Jan 24, 2020
@tpaschalis
Copy link
Contributor

@mdempsky
Hello! I've created this small commit, which I think might be the fix.

As I'm not very experienced with ELF definitions, do you mind doing a sanity-check? If I'm on the right track I will open a CL.

@ianlancetaylor
Copy link
Contributor

Seems fine. I don't think you need ELF_NOTE_GO_NAMESZ.

@gopherbot
Copy link

Change https://golang.org/cl/217857 mentions this issue: cmd/link : add trailing padding after Go ELF note

@odeke-em
Copy link
Member

Hey Ian, in the CL we changed our confidence of the proposed fix. Would you advise moving this issue to the next milestone or shall we work on it through Go1.15? Thank you.

@tpaschalis
Copy link
Contributor

Hey @odeke-em. From my side, I tried to debug the issue, but locally the toolchain is built correctly and all tests pass; I have no clue how to debug the Try-Bots, so I don't know how easy/hard the fix would be.

Both ./all.bash and GOOS=darwin GOARCH=amd64 ./bootstrap.bash seem to work. I'll rebase and send the commit again just in case.

@ianlancetaylor
Copy link
Contributor

This doesn't seem to be urgent so changing milestone to Backlog.

@ianlancetaylor ianlancetaylor modified the milestones: Go1.15, Backlog May 23, 2020
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
maksadbek added a commit to maksadbek/go that referenced this issue Mar 17, 2023
@gopherbot
Copy link

Change https://go.dev/cl/477235 mentions this issue: cmd/link: add trailing padding after Go ELF note

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
Status: Triage Backlog
Development

No branches or pull requests

5 participants