|
From: <and...@us...> - 2010-03-11 19:34:55
|
Revision: 1927
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=1927&view=rev
Author: andrewfish
Date: 2010-03-11 19:34:47 +0000 (Thu, 11 Mar 2010)
Log Message:
-----------
Fixing tools to support code sourcery ELF GCC variant for ARM. Had to add some noops for PC relatvie relocation types. Also put in a workaround for parsing dynmaic relocation section. Looks like the ARMCC uses a non standard encoding. Trying to get documenation on this and see if we can get a cleaner fix.
Modified Paths:
--------------
trunk/BaseTools/Source/C/GenFw/GenFw.c
trunk/BaseTools/Source/C/GenFw/elf_common.h
Modified: trunk/BaseTools/Source/C/GenFw/GenFw.c
===================================================================
--- trunk/BaseTools/Source/C/GenFw/GenFw.c 2010-03-11 12:01:53 UTC (rev 1926)
+++ trunk/BaseTools/Source/C/GenFw/GenFw.c 2010-03-11 19:34:47 UTC (rev 1927)
@@ -1036,14 +1036,20 @@
- (SecOffset - SecShdr->sh_addr);
break;
default:
- Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+ Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
}
} else if (Ehdr->e_machine == EM_ARM) {
switch (ELF32_R_TYPE(Rel->r_info)) {
case R_ARM_RBASE: // No relocation - no action required
- case R_ARM_PC24: // PC-relative relocations don't require modification
- case R_ARM_XPC25: // PC-relative relocations don't require modification
+
+ // Thease are all PC-relative relocations and don't require modification
+ case R_ARM_PC24:
+ case R_ARM_XPC25:
+ case R_ARM_THM_PC22:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_CALL:
break;
+
case R_ARM_ABS32:
case R_ARM_RABS32:
//
@@ -1052,7 +1058,7 @@
*(UINT32 *)Targ = *(UINT32 *)Targ - SymShdr->sh_addr + CoffSectionsOffset[Sym->st_shndx];
break;
default:
- Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
+ Error (NULL, 0, 3000, "Invalid", "WriteSections (): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
}
}
}
@@ -1126,7 +1132,7 @@
VOID
-WriteRelocations(
+WriteRelocations (
VOID
)
{
@@ -1143,7 +1149,6 @@
UINT8 *Targ;
Elf32_Phdr *DynamicSegment;
Elf32_Phdr *TargetSegment;
- static int ErrorCount = 0;
for (Index = 0, FoundRelocations = FALSE; Index < Ehdr->e_shnum; Index++) {
Elf_Shdr *RelShdr = GetShdrByIndex(Index);
@@ -1167,13 +1172,18 @@
EFI_IMAGE_REL_BASED_HIGHLOW);
break;
default:
- Error (NULL, 0, 3000, "Invalid", "%s unkown relocation %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
+ Error (NULL, 0, 3000, "Invalid", "%s unsupported ELF EM_386 relocation 0x%x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));
}
} else if (Ehdr->e_machine == EM_ARM) {
switch (ELF32_R_TYPE(Rel->r_info)) {
- case R_ARM_RBASE:
+ case R_ARM_RBASE: // No relocation - no action required
+
+ // Thease are all PC-relative relocations and don't require modification
case R_ARM_PC24:
case R_ARM_XPC25:
+ case R_ARM_THM_PC22:
+ case R_ARM_THM_JUMP19:
+ case R_ARM_CALL:
break;
case R_ARM_ABS32:
case R_ARM_RABS32:
@@ -1183,17 +1193,9 @@
EFI_IMAGE_REL_BASED_HIGHLOW
);
break;
-
- case R_ARM_CALL:
- case R_ARM_THM_MOVW_ABS_NC:
- case R_ARM_THM_MOVT_ABS:
- if (ErrorCount++ == 0) {
- Error (NULL, 0, 3000, "Invalid", "www.codesourcery.com ELF relocations not yet implemented!!!! Bad Image", mInImageName);
- }
- break;
- default:
- Error (NULL, 0, 3000, "Invalid", "%s unkown relocation %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
+ default:
+ Error (NULL, 0, 3000, "Invalid", "WriteRelocations(): %s unsupported ELF EM_ARM relocation 0x%x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));
}
} else {
Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) Ehdr->e_machine);
@@ -1229,6 +1231,9 @@
case DT_RELENT:
RelElementSize = Dyn->d_un.d_val;
break;
+
+ default:
+ break;
}
Dyn++;
}
@@ -1238,7 +1243,13 @@
for (K = 0; K < RelSize; K += RelElementSize) {
- Rel = (Elf32_Rel *) ((UINT8 *) Ehdr + DynamicSegment->p_offset + RelOffset + K);
+ if (DynamicSegment->p_paddr == 0) {
+ // This seems to be how it works on armcc???? Have the email in to find out?
+ Rel = (Elf32_Rel *) ((UINT8 *) Ehdr + DynamicSegment->p_offset + RelOffset + K);
+ } else {
+ // This is how it reads in the ELF specification
+ Rel = (Elf32_Rel *) ((UINT8 *) Ehdr + RelOffset + K);
+ }
switch (ELF32_R_TYPE (Rel->r_info)) {
case R_ARM_RBASE:
@@ -1254,7 +1265,8 @@
CoffAddFixup (CoffSectionsOffset[ELF32_R_SYM (Rel->r_info)] + (Rel->r_offset - TargetSegment->p_vaddr), EFI_IMAGE_REL_BASED_HIGHLOW);
break;
default:
- Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations, unkown type.", mInImageName);
+ Error (NULL, 0, 3000, "Invalid", "%s bad ARM dynamic relocations, unkown type %d.", mInImageName, ELF32_R_TYPE (Rel->r_info));
+ break;
}
}
break;
Modified: trunk/BaseTools/Source/C/GenFw/elf_common.h
===================================================================
--- trunk/BaseTools/Source/C/GenFw/elf_common.h 2010-03-11 12:01:53 UTC (rev 1926)
+++ trunk/BaseTools/Source/C/GenFw/elf_common.h 2010-03-11 19:34:47 UTC (rev 1927)
@@ -597,11 +597,8 @@
#define R_ARM_GOTPC 25 /* Add PC-relative GOT table address. */
#define R_ARM_GOT32 26 /* Add PC-relative GOT offset. */
#define R_ARM_PLT32 27 /* Add PC-relative PLT offset. */
-
-#define R_ARM_CALL 28 // New block for ARM Thumb2
-#define R_ARM_THM_MOVW_ABS_NC 47
-#define R_ARM_THM_MOVT_ABS 48
-
+#define R_ARM_CALL 28
+#define R_ARM_THM_JUMP19 51
#define R_ARM_GNU_VTENTRY 100
#define R_ARM_GNU_VTINHERIT 101
#define R_ARM_RSBREL32 250
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|