[PATCH] D23161: [ELF][MIPS] Produce a correct and complete set of MIPS ELF header flags

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 4 13:42:28 PDT 2016


ruiu added inline comments.

================
Comment at: ELF/Writer.cpp:1242-1262
@@ +1241,23 @@
+       Symtab<ELFT>::X->getObjectFiles()) {
+    uint32_t NewFlags = F->getObj().getHeader()->e_flags;
+    if (NewFlags & EF_MIPS_PIC)
+      // PIC code is inherently CPIC and may not set CPIC flag explicitly.
+      NewFlags |= EF_MIPS_CPIC;
+    if (ResFlags == 0) {
+      ResFlags = NewFlags;
+      continue;
+    }
+    uint32_t NewPic = NewFlags & (EF_MIPS_PIC | EF_MIPS_CPIC);
+    uint32_t ResPic = ResFlags & (EF_MIPS_PIC | EF_MIPS_CPIC);
+
+    // Check PIC / CPIC flags compatibility.
+    if (NewPic && !ResPic)
+      warning("linking non-abicalls code with abicalls file: " + F->getName());
+    if (!NewPic && ResPic)
+      warning("linking abicalls code with non-abicalls file: " + F->getName());
+
+    if (!(NewPic & EF_MIPS_PIC))
+      ResFlags &= ~EF_MIPS_PIC;
+    if (NewPic)
+      ResFlags |= EF_MIPS_CPIC;
+
----------------
I cannot find a simple rule for this code. What is the expected output for what inputs? Is there a documentation to describe the rule behind it?


Repository:
  rL LLVM

https://reviews.llvm.org/D23161





More information about the llvm-commits mailing list