[PATCH] D82899: [ELF] Resolve R_DTPREL in .debug_* referencing discarded symbols to -1

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 14:36:38 PDT 2020


MaskRay marked an inline comment as done.
MaskRay added inline comments.


================
Comment at: lld/ELF/InputSection.cpp:909
 
-    if (sym.isTls() && !Out::tlsPhdr) {
-      target->relocateNoSym(bufLoc, type, 0);
-      continue;
-    }
-
-    if (isDebug && type == target->symbolicRel) {
+    if (isDebug && (type == target->symbolicRel || expr == R_DTPREL)) {
       // Resolve relocations in .debug_* referencing (discarded symbols or ICF
----------------
psmith wrote:
> At the moment this won't work for Arm. The debug relocation is R_ARM_TLS_LDO32 which currently maps to the expr R_ABS. I don't know whether that is a problem in ARM.cpp. The only difference I can see is that R_DTPREL is relaxed which we don't want to do on Arm. It maybe that it is best to make R_ARM_TLS_LDO32 (S + A - TLS) to R_DTPREL and then prevent the relaxation for Arm as it is a bit more obvious.
> 
> I'll try and run some tests tomorrow.
Thanks for spotting this. R_DTPREL will work. ARM does not have a DTP offset (like ppc/mips/m68k) (`TLS_DTV_OFFSET` in glibc)

Added:

arm: .long tls(tlsldo) # not working currently (R_ARM_TLS_LDO32 is R_ABS)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82899





More information about the llvm-commits mailing list