]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/GenFw/Elf64Convert.c
BaseTools X64: fold PLT relocations into simple relative references
[mirror_edk2.git] / BaseTools / Source / C / GenFw / Elf64Convert.c
index 944c94b8f8b404dccdc1e3676c9b034f87896ef0..708c1a1d91a727bcab04117f9c86bb97a155ada3 100644 (file)
@@ -785,6 +785,17 @@ WriteSections64 (
             *(INT32 *)Targ = (INT32)((INT64)(*(INT32 *)Targ) - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);\r
             VerboseMsg ("Relocation:  0x%08X", *(UINT32*)Targ);\r
             break;\r
             *(INT32 *)Targ = (INT32)((INT64)(*(INT32 *)Targ) - SymShdr->sh_addr + mCoffSectionsOffset[Sym->st_shndx]);\r
             VerboseMsg ("Relocation:  0x%08X", *(UINT32*)Targ);\r
             break;\r
+\r
+          case R_X86_64_PLT32:\r
+            //\r
+            // Treat R_X86_64_PLT32 relocations as R_X86_64_PC32: this is\r
+            // possible since we know all code symbol references resolve to\r
+            // definitions in the same module (UEFI has no shared libraries),\r
+            // and so there is never a reason to jump via a PLT entry,\r
+            // allowing us to resolve the reference using the symbol directly.\r
+            //\r
+            VerboseMsg ("Treating R_X86_64_PLT32 as R_X86_64_PC32 ...");\r
+            /* fall through */\r
           case R_X86_64_PC32:\r
             //\r
             // Relative relocation: Symbol - Ip + Addend\r
           case R_X86_64_PC32:\r
             //\r
             // Relative relocation: Symbol - Ip + Addend\r
@@ -935,6 +946,7 @@ WriteRelocations64 (
             switch (ELF_R_TYPE(Rel->r_info)) {\r
             case R_X86_64_NONE:\r
             case R_X86_64_PC32:\r
             switch (ELF_R_TYPE(Rel->r_info)) {\r
             case R_X86_64_NONE:\r
             case R_X86_64_PC32:\r
+            case R_X86_64_PLT32:\r
               break;\r
             case R_X86_64_64:\r
               VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08X", \r
               break;\r
             case R_X86_64_64:\r
               VerboseMsg ("EFI_IMAGE_REL_BASED_DIR64 Offset: 0x%08X", \r