golang/go

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

Open

#36,719 opened on Jan 24, 2020

View on GitHub
 (7 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsFixcompiler/runtimehelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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

Contributor guide