https://sourceware.org/bugzilla/show_bug.cgi?id=33262

            Bug ID: 33262
           Summary: unknown program property type -1342144512 in
                    .note.gnu.property section using
                    -mno-direct-extern-access
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: thiago at kde dot org
                CC: ian at airs dot com
  Target Milestone: ---

It looks like Gold is not handling properties of type
GNU_PROPERTY_UINT32_OR_LO, or potentially any of the OR or AND properties.

Testcase:
$ cat a.c
#define EXPORT __attribute__((visibility("protected")))

EXPORT void my_func() {}

$ cat b.c
#define EXPORT __attribute__((visibility("protected")))
EXPORT void my_func(void);

static void (*vtable[])(void) = {
    &my_func,
};
void *f() { my_func(); return vtable; }

When either file is compiled by GCC with -mno-direct-extern-access or Clang
with its equivalent option, the ELF notes for the .o files contain this
property:

$ eu-readelf -n a.o b.o
a.o:
Note section [ 6] '.note.gnu.property' of 80 bytes at offset 0x68:
  Owner          Data size  Type
  GNU                   16  GNU_PROPERTY_TYPE_0
    unknown_type 0xb0008000 data: 01 00 00 00
  GNU                   32  GNU_PROPERTY_TYPE_0
    X86 0xc0010002 data: 00 00 00 00
    X86 0xc0010001 data: 01 00 00 00
b.o:
Note section [ 9] '.note.gnu.property' of 80 bytes at offset 0x88:
  Owner          Data size  Type
  GNU                   16  GNU_PROPERTY_TYPE_0
    unknown_type 0xb0008000 data: 01 00 00 00
  GNU                   32  GNU_PROPERTY_TYPE_0
    X86 0xc0010002 data: 00 00 00 00
    X86 0xc0010001 data: 01 00 00 00

binutils readelf decodes it as GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS:

$ readelf -n a.o b.o

File: a.o
Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0
      Properties: 1_needed: indirect external access
  GNU                  0x00000020       NT_GNU_PROPERTY_TYPE_0
      Properties: x86 ISA used: 
        x86 feature used: x86

File: b.o
Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_PROPERTY_TYPE_0
      Properties: 1_needed: indirect external access
  GNU                  0x00000020       NT_GNU_PROPERTY_TYPE_0
      Properties: x86 ISA used: 
        x86 feature used: x86

When compiled with the bfd ld, the above produces no warning and does produce
the ELF note:

$ gcc -fPIC -O2 -fvisibility=hidden -mno-direct-extern-access -shared -o a.so
a.c b.c
$ readelf -n a.so

Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000030       NT_GNU_PROPERTY_TYPE_0
      Properties: 1_needed: indirect external access
        x86 feature used: x86
        x86 ISA used: 

However, gold produces a warning:

$ gcc -fuse-ld=gold -fPIC -O2 -fvisibility=hidden -mno-direct-extern-access
-shared -o a.so a.c b.c
/usr/bin/ld.gold: warning: /tmp/cc9linBj.o: unknown program property type
-1342144512 in .note.gnu.property section

It does add the note to the output:

$ readelf -n a.so

Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000020       NT_GNU_PROPERTY_TYPE_0
      Properties: 1_needed: indirect external access
        x86 feature used: x86

However, it's very likely it's not properly handling the notes and is just
copying one of the input files' notes, instead of OR'ing the payloads together.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to