Bug 225302 - sys/elf.h: we define Elf32_Nhdr and Elf64_Nhdr but not Elf_Nhdr
Summary: sys/elf.h: we define Elf32_Nhdr and Elf64_Nhdr but not Elf_Nhdr
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-18 17:56 UTC by Val Packett
Modified: 2018-01-18 21:20 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Val Packett 2018-01-18 17:56:00 UTC
Other operating systems have a typedef called Elf_Nhdr. Why is it absent on FreeBSD? Can we add it?

From Mesa: https://lists.freedesktop.org/archives/mesa-dev/2018-January/182471.html
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2018-01-18 19:35:47 UTC
No objection to the change; trying to find some published standard to justify the name.  If that ends up being "well, Linux does it," that's fine, too.  But I'll spend a little time looking.

So far: The note structure is described anonymously in the original Sun ELF document, as well as in SysV ABI 4.1.
Comment 2 Conrad Meyer freebsd_committer freebsd_triage 2018-01-18 20:13:38 UTC
(In fact, I'm having trouble figuring out where this is defined on Linux.  elfutils-libelf defines a Gelf_Nhdr.  Is that it?  If so, it's so old elfutils' git history isn't helping me find a source.)
Comment 3 Val Packett 2018-01-18 20:17:32 UTC
Apparently OpenBSD took that from NetBSD in 2001: https://github.com/openbsd/src/commit/6917584ad119d2e4f5e1a1bed33d2ecab5dbc26a

And NetBSD in 1999 did this to match "various SVR4 ABIs" https://github.com/IIJ-NetBSD/netbsd-src/commit/27bb633dcae90dbb476a3e4d9bc5895d68b20393
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2018-01-18 20:23:22 UTC
(In reply to Greg V from comment #3)
Thanks for digging that up!
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-01-18 21:20:53 UTC
A commit references this bug:

Author: cem
Date: Thu Jan 18 21:19:57 UTC 2018
New revision: 328137
URL: https://svnweb.freebsd.org/changeset/base/328137

Log:
  Add Elf_Nhdr definition to match NetBSD, OpenBSD, Linux

  The mesa port started to use this type and fails to build without it.

  NetBSD: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec_elf.h.diff?r1=1.26&r2=1.27&f=h
  OpenBSD: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/exec_elf.h.diff?r1=1.21&r2=1.22&f=h

  PR:		225302
  Reported by:	Greg V <greg AT unrelenting.technology>
  Sponsored by:	Dell EMC Isilon

Changes:
  head/sys/sys/elf_common.h