]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFw/Elf64Convert.c
BaseTools/GenFw: ignore dynamic RELA sections
[mirror_edk2.git] / BaseTools / Source / C / GenFw / Elf64Convert.c
index 708c1a1d91a727bcab04117f9c86bb97a155ada3..9b409b615e4085c5f7785d70865f0489e104b299 100644 (file)
@@ -682,6 +682,20 @@ WriteSections64 (
       continue;\r
     }\r
 \r
+    //\r
+    // If this is a ET_DYN (PIE) executable, we will encounter a dynamic SHT_RELA\r
+    // section that applies to the entire binary, and which will have its section\r
+    // index set to #0 (which is a NULL section with the SHF_ALLOC bit cleared).\r
+    //\r
+    // In the absence of GOT based relocations (which we currently don't support),\r
+    // this RELA section will contain redundant R_xxx_RELATIVE relocations, one\r
+    // for every R_xxx_xx64 relocation appearing in the per-section RELA sections.\r
+    // (i.e., .rela.text and .rela.data)\r
+    //\r
+    if (RelShdr->sh_info == 0) {\r
+      continue;\r
+    }\r
+\r
     //\r
     // Relocation section found.  Now extract section information that the relocations\r
     // apply to in the ELF data and the new COFF data.\r