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

            Bug ID: 33409
           Summary: Check for 1_NEEDED note when emitting relocation error
           Product: binutils
           Version: 2.45
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: sam at gentoo dot org
                CC: hjl.tools at gmail dot com
  Target Milestone: ---

```
$ gcc a.c -o a.so -shared -mno-direct-extern-access
$ gcc b.c a.so -shared -mdirect-extern-access
/usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/bin/ld:
/tmp/cc9vITO3.o: warning: relocation against `bar' in read-only section `.text'
/usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/bin/ld:
/tmp/cc9vITO3.o: relocation R_X86_64_PC32 against undefined symbol `bar' can
not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/16/../../../../x86_64-pc-linux-gnu/bin/ld:
final link failed: bad value
collect2: error: ld returned 1 exit status
```

```
$ readelf -n a.so

Displaying notes found in: .note.gnu.build-id
  Owner                Data size        Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID
bitstring)
    Build ID: 6cfad988cc98b56468a2bf6db515e199abc99d96

Displaying notes found in: .note.gnu.property
  Owner                Data size        Description
  GNU                  0x00000038       NT_GNU_PROPERTY_TYPE_0
      Properties: memory seal
        1_needed: indirect external access
        x86 feature used: x86
        x86 ISA used: x86-64-baseline
```

If we see that a.so has the 1_needed note, can we say "recompile with -fPIC (or
-mno-direct-extern-access)"?

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

Reply via email to