Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12444 closed enhancement (fixed)

Provide elf.h to applications

Reported by: simonsouth Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: yes Platform: All

Description

ELF-based UNIX systems commonly provide a public header file, elf.h, that defines the various structures and constants used by the ELF file format. (GNU libc includes one, for instance.)

Haiku does not, though one can easily be assembled from the definitions in its private header files elf_common.h, elf32.h and elf64.h.

The first patch I'm attaching does exactly that, creating elf.h in headers/os/kernel (the most sensible location, it seems to me, from the default search paths) entirely from existing code. This includes Haiku's C++ extensions to the ELF structures but not the handful of definitions used only by itself internally.

This change allows UNIX applications that rely on the presence of elf.h, among them GNU Emacs, to build on Haiku without modification.

The second patch eliminates the duplication of code created by the first by refactoring Haiku itself to use the new, public elf.h header. Specifically, it

  • Removes now-redundant code from elf_common.h and deletes elf32.h and elf64.h altogether.
  • Renames elf_common.h to elf_private.h (following the pattern of existing, adjacent files, such as architecture_private.h and node_monitor_private.h) as it now contains only Haiku-internal definitions.
  • Updates the files that included the original headers to build with the private and public ELF header files together, including minor updates to match the definitions in the public header file (removing the struct keyword, basically).

Attachments (2)

0001-system-Provide-elf.h-to-applications.patch (18.4 KB ) - added by simonsouth 4 years ago.
Provide elf.h to applications
0002-system-Build-using-public-elf.h-header.patch (41.7 KB ) - added by simonsouth 4 years ago.
Haiku: Build using public and private ELF header files

Download all attachments as: .zip

Change History (11)

by simonsouth, 4 years ago

Provide elf.h to applications

comment:1 by simonsouth, 4 years ago

Has a Patch: set

by simonsouth, 4 years ago

Haiku: Build using public and private ELF header files

comment:2 by Max-Might, 4 years ago

This is nice.

I needed elf.h when I tried to port some lib to Haiku. It was libunwind if I remember correctly. It may need other stuff too but this was the first error I hit. Thanks for the patches, will try again when I have the time (and someone merges this).

comment:3 by pulkomandy, 4 years ago

There is a recipe for libunwind in haikuports, I think the recipe includes a minimal elf.h. But providing it from Haiku side is cleaner. cmake will also make use of it.

comment:4 by korli, 4 years ago

There probably is a copyright problem if we remove Travis name, without checking which part he originated. It might easier to just ask him to agree on the change.

comment:5 by simonsouth, 4 years ago

Good point. I'll write to him unless you intend to.

in reply to:  5 comment:6 by korli, 4 years ago

Replying to simonsouth:

Good point. I'll write to him unless you intend to.

You can write to him, or contact him on IRC (nickname geist). If he can confirm in this ticket with a short comment, that would be cool.

comment:7 by jessicah, 4 years ago

Resolution: fixed
Status: newclosed

Applied in hrev49754.

Travis' copyright is still present in elf_private.h, so I'm not sure where the issue is. Public headers shouldn't list authors, and authorship can be tracked via commit history.

comment:8 by jessicah, 4 years ago

FYI, Travis approved the changes to copyright via IRC.

comment:9 by korli, 4 years ago

Fine. IIRC a part of the private header with Travis' copyright was then included in a public header without this same copyright, which then looks like a copyright removal.

Note: See TracTickets for help on using tickets.