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

            Bug ID: 34681
           Summary: ld: $d mapping symbol address outside .eh_frame
                    section range
           Product: binutils
           Version: 2.47
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: jiannmao at qq dot com
  Target Milestone: ---

## Summary

After linking three objects compiled by clang, the output shared object
contains `$d` mapping symbols whose `st_value` does not fall inside the
`.eh_frame` section range that their `st_shndx` points to.

## Environment

- GNU ld 2.47, aarch64 (Linux)
- clang 24

## Reproducer

```bash
echo 'int f0(int x) { return x + 0; }' > t0.cpp
echo 'int f1(int x) { return x + 1; }' > t1.cpp
echo 'int f2(int x) { return x + 2; }' > t2.cpp
clang++ -O2 -c t0.cpp -o t0.o
clang++ -O2 -c t1.cpp -o t1.o
clang++ -O2 -c t2.cpp -o t2.o
ld -shared t0.o t1.o t2.o -o repro.so
```

## Actual result

```
$ readelf -SW repro.so | grep eh_frame
  [ 6] .eh_frame    PROGBITS    0000000000000240 000240 000054 00  A ...

$ readelf -sW repro.so | grep '$d'
    14: 0000000000000240     0 NOTYPE  LOCAL  DEFAULT    6 $d
    18: 0000000000000240     0 NOTYPE  LOCAL  DEFAULT    6 $d
    22: 0000000000000230     0 NOTYPE  LOCAL  DEFAULT    6 $d   <-- out of
range
```

`.eh_frame` spans 0x240–0x294, but the third symbol's value is 0x230, below
the section start, while its `st_shndx` says `.eh_frame`.

## Notes

- The same sources compiled with g++ and linked with ld show no out-of-range
symbols.
- The same sources compiled with clang++ and linked with lld show no
out-of-range symbols.

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

Reply via email to