llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.82k stars 10.99k forks source link

[libc] add `link.h`/`elf.h` #94128

Open SchrodingerZhu opened 1 month ago

SchrodingerZhu commented 1 month ago

These definitions are currently missing in libc. They are useful in the startup library and the vdso parts.

See https://github.com/llvm/llvm-project/pull/91572

changkhothuychung commented 3 weeks ago

I can take this issue if this is available.

michaelrj-google commented 3 weeks ago

assigned

changkhothuychung commented 3 weeks ago

@michaelrj-google thanks for assigning this to me. Can you give me some instructions on what to do with this one? What functions am i going to add to those files, and what directory am I putting it under?

michaelrj-google commented 3 weeks ago

@SchrodingerZhu can hopefully tell you more, I'm not sure what he needs from these headers.

SchrodingerZhu commented 3 weeks ago

Currently, I am in need of

changkhothuychung commented 3 weeks ago

@SchrodingerZhu I have a few questions

Dont we link linux when building LLVM? So we can just include the elf.h file of linux kernel and use the values right? Why do we need to move it over to llvm?

what folder under libc should I put these files?

nickdesaulniers commented 2 weeks ago

Take a look at glibc's elf.h: https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/elf.h;h=33aea7f743b885c5d74736276e55ef21756293ee;hb=HEAD

or musl's: https://git.musl-libc.org/cgit/musl/tree/include/elf.h

Some of the definitions there are useful for a libc to provide (and include via our hdr/ proxy pattern). Specifically, look at what https://github.com/llvm/llvm-project/pull/91572/files is using from elf.h. We should have our own, and include that.

SchrodingerZhu commented 2 weeks ago

what folder under libc should I put these files?

I think you can following the convention to put definitions inside libc/include/ with types and macros separated into two sub folders.

changkhothuychung commented 2 weeks ago

@SchrodingerZhu I will first create a patch with macors from elf.h file.

Do you need exactly everything from the file https://github.com/torvalds/linux/blob/master/include/uapi/linux/elf.h? Or is there anything else I should be aware of? Thanks.