[1/4] Initial support for GNU_PROPERTY_1_NEEDED
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
1. Add GNU_PROPERTY_1_NEEDED:
#define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO
to indicate the needed properties by the object file.
2. Add GNU_PROPERTY_1_NEEDED_SINGLE_GLOBAL_DEFINITION:
#define GNU_PROPERTY_1_NEEDED_SINGLE_GLOBAL_DEFINITION (1U << 0)
to indicate that the object file requires canonical function pointers and
cannot be used with copy relocation.
3. Scan GNU_PROPERTY_1_NEEDED property and store it in l_1_needed.
---
elf/elf.h | 17 +++++++++++++++++
sysdeps/generic/dl-prop.h | 9 ++++++++-
sysdeps/generic/link_map.h | 3 ++-
sysdeps/x86/dl-prop.h | 19 ++++++++++++++-----
sysdeps/x86/link_map.h | 2 ++
5 files changed, 43 insertions(+), 7 deletions(-)
Comments
* H. J. Lu via Libc-alpha:
> diff --git a/elf/elf.h b/elf/elf.h
> index 2a62b98d4a..45b107fdcf 100644
> --- a/elf/elf.h
> +++ b/elf/elf.h
> @@ -1310,6 +1310,23 @@ typedef struct
> /* No copy relocation on protected data symbol. */
> #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
>
> +/* A 4-byte unsigned integer property: A bit is set if it is set in all
> + relocatable inputs. */
> +#define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
> +#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
> +
> +/* A 4-byte unsigned integer property: A bit is set if it is set in any
> + relocatable inputs. */
> +#define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
> +#define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff
> +
> +/* The needed properties by the object file. */
> +#define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO
> +
> +/* Set if the object file requires canonical function pointers and
> + cannot be used with copy relocation. */
> +#define GNU_PROPERTY_1_NEEDED_SINGLE_GLOBAL_DEFINITION (1U << 0)
> +
> /* Processor-specific semantics, lo */
> #define GNU_PROPERTY_LOPROC 0xc0000000
> /* Processor-specific semantics, hi */
Please add a stable link to the full specification.
I think we need more bits: one bit to indicate the status (in this
patch), and another bit to indicate linker support for this feature.
And perhaps yet another to indicate incompatibility with this feature.
Thanks,
Florian
On Mon, Jun 21, 2021 at 12:06 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > diff --git a/elf/elf.h b/elf/elf.h
> > index 2a62b98d4a..45b107fdcf 100644
> > --- a/elf/elf.h
> > +++ b/elf/elf.h
> > @@ -1310,6 +1310,23 @@ typedef struct
> > /* No copy relocation on protected data symbol. */
> > #define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
> >
> > +/* A 4-byte unsigned integer property: A bit is set if it is set in all
> > + relocatable inputs. */
> > +#define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
> > +#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
> > +
> > +/* A 4-byte unsigned integer property: A bit is set if it is set in any
> > + relocatable inputs. */
> > +#define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
> > +#define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff
> > +
> > +/* The needed properties by the object file. */
> > +#define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO
> > +
> > +/* Set if the object file requires canonical function pointers and
> > + cannot be used with copy relocation. */
> > +#define GNU_PROPERTY_1_NEEDED_SINGLE_GLOBAL_DEFINITION (1U << 0)
> > +
> > /* Processor-specific semantics, lo */
> > #define GNU_PROPERTY_LOPROC 0xc0000000
> > /* Processor-specific semantics, hi */
>
> Please add a stable link to the full specification.
I will work on it.
> I think we need more bits: one bit to indicate the status (in this
> patch), and another bit to indicate linker support for this feature.
> And perhaps yet another to indicate incompatibility with this feature.
>
There is
#define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO
Since the setting on output is ORed from inputs, one bit is
sufficient.
@@ -1310,6 +1310,23 @@ typedef struct
/* No copy relocation on protected data symbol. */
#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2
+/* A 4-byte unsigned integer property: A bit is set if it is set in all
+ relocatable inputs. */
+#define GNU_PROPERTY_UINT32_AND_LO 0xb0000000
+#define GNU_PROPERTY_UINT32_AND_HI 0xb0007fff
+
+/* A 4-byte unsigned integer property: A bit is set if it is set in any
+ relocatable inputs. */
+#define GNU_PROPERTY_UINT32_OR_LO 0xb0008000
+#define GNU_PROPERTY_UINT32_OR_HI 0xb000ffff
+
+/* The needed properties by the object file. */
+#define GNU_PROPERTY_1_NEEDED GNU_PROPERTY_UINT32_OR_LO
+
+/* Set if the object file requires canonical function pointers and
+ cannot be used with copy relocation. */
+#define GNU_PROPERTY_1_NEEDED_SINGLE_GLOBAL_DEFINITION (1U << 0)
+
/* Processor-specific semantics, lo */
#define GNU_PROPERTY_LOPROC 0xc0000000
/* Processor-specific semantics, hi */
@@ -47,7 +47,14 @@ static inline int __attribute__ ((always_inline))
_dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
uint32_t datasz, void *data)
{
- return 0;
+ /* Continue until GNU_PROPERTY_1_NEEDED is found. */
+ if (type == GNU_PROPERTY_1_NEEDED)
+ {
+ if (datasz == 4)
+ l->l_1_needed = *(unsigned int *) data;
+ return 0;
+ }
+ return 1;
}
#endif /* _DL_PROP_H */
@@ -1 +1,2 @@
-/* No architecture specific definitions. */
+/* GNU_PROPERTY_1_NEEDED of this object. */
+unsigned int l_1_needed;
@@ -97,6 +97,7 @@ _dl_process_property_note (struct link_map *l, const ElfW(Nhdr) *note,
const ElfW(Addr) start = (ElfW(Addr)) note;
+ unsigned int needed_1 = 0;
unsigned int feature_1_and = 0;
unsigned int isa_1_needed = 0;
unsigned int last_type = 0;
@@ -141,7 +142,8 @@ _dl_process_property_note (struct link_map *l, const ElfW(Nhdr) *note,
last_type = type;
if (type == GNU_PROPERTY_X86_FEATURE_1_AND
- || type == GNU_PROPERTY_X86_ISA_1_NEEDED)
+ || type == GNU_PROPERTY_X86_ISA_1_NEEDED
+ || type == GNU_PROPERTY_1_NEEDED)
{
/* The sizes of types which we are searching for are
4 bytes. There is no point to continue if this
@@ -151,12 +153,18 @@ _dl_process_property_note (struct link_map *l, const ElfW(Nhdr) *note,
/* NB: Stop the scan only after seeing all types which
we are searching for. */
- _Static_assert ((GNU_PROPERTY_X86_ISA_1_NEEDED >
- GNU_PROPERTY_X86_FEATURE_1_AND),
+ _Static_assert (((GNU_PROPERTY_X86_ISA_1_NEEDED
+ > GNU_PROPERTY_X86_FEATURE_1_AND)
+ && (GNU_PROPERTY_X86_FEATURE_1_AND
+ > GNU_PROPERTY_1_NEEDED)),
"GNU_PROPERTY_X86_ISA_1_NEEDED > "
- "GNU_PROPERTY_X86_FEATURE_1_AND");
+ "GNU_PROPERTY_X86_FEATURE_1_AND && "
+ "GNU_PROPERTY_X86_FEATURE_1_AND > "
+ "GNU_PROPERTY_1_NEEDED");
if (type == GNU_PROPERTY_X86_FEATURE_1_AND)
feature_1_and = *(unsigned int *) ptr;
+ else if (type == GNU_PROPERTY_1_NEEDED)
+ needed_1 = *(unsigned int *) ptr;
else
{
isa_1_needed = *(unsigned int *) ptr;
@@ -187,9 +195,10 @@ _dl_process_property_note (struct link_map *l, const ElfW(Nhdr) *note,
}
/* We get here only if there is one or no GNU property note. */
- if (isa_1_needed != 0 || feature_1_and != 0)
+ if (needed_1 != 0 || isa_1_needed != 0 || feature_1_and != 0)
{
l->l_property = lc_property_valid;
+ l->l_1_needed = needed_1;
l->l_x86_isa_1_needed = isa_1_needed;
l->l_x86_feature_1_and = feature_1_and;
}
@@ -29,3 +29,5 @@ unsigned int l_x86_feature_1_and;
/* GNU_PROPERTY_X86_ISA_1_NEEDED of this object. */
unsigned int l_x86_isa_1_needed;
+
+#include <sysdeps/generic/link_map.h>