[lld] [LLD][AARCH64] lld incorrectly handles .eh_frame when it has a non-zero offset within its output section. (PR #65966)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 06:16:17 PDT 2023


================
@@ -583,9 +583,14 @@ static uint64_t readFdeAddr(uint8_t *buf, int size) {
 uint64_t EhFrameSection::getFdePc(uint8_t *buf, size_t fdeOff,
                                   uint8_t enc) const {
   // The starting address to which this FDE applies is
-  // stored at FDE + 8 byte.
+  // stored at FDE + 8 byte. And this offset is within
+  // the .eh_frame section.
   size_t off = fdeOff + 8;
   uint64_t addr = readFdeAddr(buf + off, enc & 0xf);
+  // Adding outSecOff as finalizeAddressDependentContent()
+  // may have altered the corresponding outSecOff. This is
+  // required to get the correct PC relative offset.
+  off = off + outSecOff;
----------------
smithp35 wrote:

I agree, I think
```
if ((enc & 0x70) == DW_EH_PE_pcrel)
  return addr + getParent()->addr + off + outSecOff;
```
Is easier to understand than modifying off.

https://github.com/llvm/llvm-project/pull/65966


More information about the llvm-commits mailing list