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 · 3 comments
Open

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

mdempsky opened this issue Jan 24, 2020 · 3 comments
Labels
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jan 24, 2020

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 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

This comment has been minimized.

Copy link

@tpaschalis tpaschalis commented Feb 5, 2020

@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

This comment has been minimized.

Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 5, 2020

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Feb 5, 2020

Change https://golang.org/cl/217857 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.