]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenFw: Fixed R_AARCH64_CALL26/R_AARCH64_JUMP26 when referring to start...
authorOlivier Martin <olivier.martin@arm.com>
Wed, 5 Nov 2014 18:56:17 +0000 (18:56 +0000)
committeroliviermartin <oliviermartin@Edk2>
Wed, 5 Nov 2014 18:56:17 +0000 (18:56 +0000)
When R_AARCH64_CALL26/R_AARCH64_JUMP26 relocations referred to static
functions, they sometime refer to the start of the '.text' section + addend.
It means the addend is different of '0'.
The non-patched code (before applying the relocation) already contains
the correct offset.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Reviewed-by: Yingke Liu <yingke.d.liu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16302 6f19259b-4bc3-4df7-8a09-765794883524

BaseTools/Source/C/GenFw/Elf64Convert.c

index 526ab5d41f3dbf47918958735dc9e1f8d21c68bd..290f04cb9837ca88121b998a7c11753ff2b9513e 100644 (file)
@@ -710,13 +710,15 @@ WriteSections64 (
             break;\r
 \r
           case R_AARCH64_CALL26:\r
-            if  (Rel->r_addend != 0 ) { /* TODO */\r
-              Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_CALL26 Need to fixup with addend!.");\r
-            }\r
-            break;\r
-\r
           case R_AARCH64_JUMP26:\r
-            if  (Rel->r_addend != 0 ) { /* TODO : AArch64 '-O2' optimisation. */\r
+            if  (Rel->r_addend != 0 ) {\r
+              // Some references to static functions sometime start at the base of .text + addend.\r
+              // It is safe to ignore these relocations because they patch a `BL` instructions that\r
+              // contains an offset from the instruction itself and there is only a single .text section.\r
+              // So we check if the symbol is a "section symbol"\r
+              if (ELF64_ST_TYPE (Sym->st_info) == STT_SECTION) {\r
+                break;\r
+              }\r
               Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_JUMP26 Need to fixup with addend!.");\r
             }\r
             break;\r