diff mbox series

[v7,4/6] include/elf: Add defines related to GNU property notes for AArch64

Message ID 20190803210803.5701-5-richard.henderson@linaro.org
State New
Headers show
Series [v7,1/6] linux-user/aarch64: Reset btype for signals | expand

Commit Message

Richard Henderson Aug. 3, 2019, 9:08 p.m. UTC
These are all of the defines required to parse
GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
Other missing defines related to other GNU program headers
and notes are elided for now.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/elf.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Peter Maydell Aug. 20, 2019, 3:39 p.m. UTC | #1
On Sat, 3 Aug 2019 at 22:08, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> These are all of the defines required to parse
> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> Other missing defines related to other GNU program headers
> and notes are elided for now.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

What's the authoritative source for these definitions? I
tried looking in glibc, binutils and the kernel without
any luck.

thanks
-- PMM
Richard Henderson Aug. 20, 2019, 3:59 p.m. UTC | #2
On 8/20/19 8:39 AM, Peter Maydell wrote:
> On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> These are all of the defines required to parse
>> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
>> Other missing defines related to other GNU program headers
>> and notes are elided for now.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> 
> What's the authoritative source for these definitions? I
> tried looking in glibc, binutils and the kernel without
> any luck.

Presumably the true "authoritative" source is an ARM document, but I don't have
that handy.

For binutils, the defines are in include/elf/common.h:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD

The upstream kernel is also lacking the defines, as they're part of the ARM
patch set that is still in flight.  The defines are still not present in glibc
as of today.


r~
Dave Martin Aug. 20, 2019, 3:59 p.m. UTC | #3
On Tue, Aug 20, 2019 at 04:39:01PM +0100, Peter Maydell wrote:
> On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> <richard.henderson@linaro.org> wrote:
> >
> > These are all of the defines required to parse
> > GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> > Other missing defines related to other GNU program headers
> > and notes are elided for now.
> >
> > Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>
> What's the authoritative source for these definitions? I
> tried looking in glibc, binutils and the kernel without
> any luck.

For the kernel, additions to the user elf.h are still under
discussion. [3]

For the relevant draft ELF/ABI specs, see [1], [2].

Cheers
---Dave


[1] https://github.com/hjl-tools/linux-abi/wiki/linux-abi-draft.pdf
[2] https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-draft.pdf

[3] [PATCH v8 22/27] binfmt_elf: Extract .note.gnu.property from an ELF file
https://lore.kernel.org/lkml/20190813205225.12032-23-yu-cheng.yu@intel.com/
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Dave Martin Aug. 20, 2019, 4:03 p.m. UTC | #4
On Tue, Aug 20, 2019 at 04:59:50PM +0100, Richard Henderson wrote:
> On 8/20/19 8:39 AM, Peter Maydell wrote:
> > On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> > <richard.henderson@linaro.org> wrote:
> >>
> >> These are all of the defines required to parse
> >> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> >> Other missing defines related to other GNU program headers
> >> and notes are elided for now.
> >>
> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> > 
> > What's the authoritative source for these definitions? I
> > tried looking in glibc, binutils and the kernel without
> > any luck.
> 
> Presumably the true "authoritative" source is an ARM document, but I don't have
> that handy.
> 
> For binutils, the defines are in include/elf/common.h:
> 
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD
> 
> The upstream kernel is also lacking the defines, as they're part of the ARM
> patch set that is still in flight.  The defines are still not present in glibc
> as of today.


The AArch64 spec is here:

https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2019q2-documentation

Cheers
---Dave
Peter Maydell Aug. 20, 2019, 4:07 p.m. UTC | #5
On Tue, 20 Aug 2019 at 16:59, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 8/20/19 8:39 AM, Peter Maydell wrote:
> > On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> > <richard.henderson@linaro.org> wrote:
> >>
> >> These are all of the defines required to parse
> >> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> >> Other missing defines related to other GNU program headers
> >> and notes are elided for now.
> >>
> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> >
> > What's the authoritative source for these definitions? I
> > tried looking in glibc, binutils and the kernel without
> > any luck.
>
> Presumably the true "authoritative" source is an ARM document, but I don't have
> that handy.
>
> For binutils, the defines are in include/elf/common.h:
>
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD

Thanks.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
diff mbox series

Patch

diff --git a/include/elf.h b/include/elf.h
index 3501e0c8d0..7c4dc4b2cc 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -26,9 +26,13 @@  typedef int64_t  Elf64_Sxword;
 #define PT_NOTE    4
 #define PT_SHLIB   5
 #define PT_PHDR    6
+#define PT_LOOS    0x60000000
+#define PT_HIOS    0x6fffffff
 #define PT_LOPROC  0x70000000
 #define PT_HIPROC  0x7fffffff
 
+#define PT_GNU_PROPERTY   (PT_LOOS + 0x474e553)
+
 #define PT_MIPS_REGINFO   0x70000000
 #define PT_MIPS_RTPROC    0x70000001
 #define PT_MIPS_OPTIONS   0x70000002
@@ -1651,6 +1655,24 @@  typedef struct elf64_shdr {
 #define NT_ARM_HW_WATCH 0x403           /* ARM hardware watchpoint registers */
 #define NT_ARM_SYSTEM_CALL      0x404   /* ARM system call number */
 
+/* Defined note types for GNU systems.  */
+
+#define NT_GNU_PROPERTY_TYPE_0  5       /* Program property */
+
+/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0).  */
+
+#define GNU_PROPERTY_STACK_SIZE                 1
+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED       2
+
+#define GNU_PROPERTY_LOPROC                     0xc0000000
+#define GNU_PROPERTY_HIPROC                     0xdfffffff
+#define GNU_PROPERTY_LOUSER                     0xe0000000
+#define GNU_PROPERTY_HIUSER                     0xffffffff
+
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND      0xc0000000
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI      (1u << 0)
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC      (1u << 1)
+
 /*
  * Physical entry point into the kernel.
  *