[PATCH] D85994: [LLD][PowerPC] Add check in LLD to produce an error for missing TLSGD/TLSLD

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 14:19:50 PDT 2020


MaskRay added a comment.

In D85994#2222489 <https://reviews.llvm.org/D85994#2222489>, @stefanp wrote:

> I've tried to address the concerns for this patch. I'm sorry that it took so long to make the code changes.
>
> I did try to generate the assembly equivalent of the tests but those will not work. The PowerPC MC layer will assert if I try to generate an object file from assembly that does not have the correct relocations.
> I did the fix the tests using the original suggestion of `yaml2obj`.
>
> I also fixed the out of bounds problem by passing the start iterator to the function.

The YAML tests share a large portion in common. You can find some existing use cases of `yamlobj -D`. It is also possible to rewrite the tests with assembly, with might be even simpler. You can use `.reloc` to synthesize relocations.



================
Comment at: lld/ELF/Relocations.cpp:1330
+        // start.
+        const RelTy &prevRel = *(i - 2);
+        RelType prevType = prevRel.getType(config->isMips64EL);
----------------
i-2 may go out of bounds.


================
Comment at: lld/ELF/Relocations.cpp:1332
+        RelType prevType = prevRel.getType(config->isMips64EL);
+        if(prevRel.r_offset != rel.r_offset ||
+           (prevType != R_PPC64_TLSGD && prevType != R_PPC64_TLSLD))
----------------
`if `


================
Comment at: lld/ELF/Relocations.cpp:1334
+           (prevType != R_PPC64_TLSGD && prevType != R_PPC64_TLSLD))
+          error("Call to __tls_get_addr is missing a "
+                "R_PPC64_TLSGD/R_PPC64_TLSLD relocation." +
----------------
errorOrWarn


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

https://reviews.llvm.org/D85994



More information about the llvm-commits mailing list