[PATCH] D122459: [ELF] Fix relocations against .eh_frame

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 25 16:25:39 PDT 2022


MaskRay added a comment.

> [ELF] Fix relocations against .eh_frame

`[ELF] Fix relocations from .eh_frame`. By `against`, I am thinking of relocations referencing `.eh_frame`.



================
Comment at: lld/ELF/InputSection.cpp:1361
+  uint64_t addend = offset - piece.inputOff;
+  return piece.outputOff + addend;
+}
----------------
Avoid used-once variable.


================
Comment at: lld/ELF/InputSection.h:333
+  // Returns the SectionPiece at a given input section offset.
+  EhSectionPiece *getSectionPiece(uint64_t offset);
+  const EhSectionPiece *getSectionPiece(uint64_t offset) const {
----------------
Only one overload is used. Remove the other one.


================
Comment at: lld/test/ELF/mips-eh_frame-offset.s:1
+# REQUIRES: mips
+## Check that offsets for emitted relocations are correct when linking multiple
----------------
Perhaps `mips-emit-relocs-eh-frame.s`

This seems a generic problem, not specific to mips.
It seems to make sense to add `emit-relocs-eh-frame.s` for an x86-64 test.


================
Comment at: lld/test/ELF/mips-eh_frame-offset.s:5
+
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t-1.o
+# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t-2.o
----------------
```
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o
# RUN: ld.lld --emit-relocs --entry=0 %t.o %t.o -o %t
```


================
Comment at: lld/test/ELF/mips-eh_frame-offset.s:10
+
+# RELOCS:        [[OFFSET:0x[0-9,A-F]+]] R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text 0x0
+# RELOCS-NOT:    [[OFFSET]] R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text 0x10
----------------
`[[#%X,OFFSET:]]`



================
Comment at: lld/test/ELF/mips-eh_frame-offset.s:11
+# RELOCS:        [[OFFSET:0x[0-9,A-F]+]] R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text 0x0
+# RELOCS-NOT:    [[OFFSET]] R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text 0x10
+
----------------
`[[#%X,OFFSET+24]]` 

Prefer positive patterns to negative patterns.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122459/new/

https://reviews.llvm.org/D122459



More information about the llvm-commits mailing list