Start working on support for www.codesourcey.com tool chain. Defacto standard ARM...
authorandrewfish <andrewfish@c2973edb-eda0-4c78-bc6a-9341b269661f>
Wed, 10 Mar 2010 01:02:15 +0000 (01:02 +0000)
committerandrewfish <andrewfish@c2973edb-eda0-4c78-bc6a-9341b269661f>
Wed, 10 Mar 2010 01:02:15 +0000 (01:02 +0000)
git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1923 c2973edb-eda0-4c78-bc6a-9341b269661f

Conf/build_rule.template
Conf/tools_def.template
Source/C/GenFw/GenFw.c
Source/C/GenFw/elf_common.h

index 0f2921c..3cc7ea3 100644 (file)
         "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}\r
         "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}\r
 \r
+    <Command.ARMGCC>\r
+        "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}\r
+\r
+\r
 [C-Header-File]\r
     <InputFile>\r
         *.h, *.H\r
     <Command.RVCT>\r
         "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)\r
     \r
-    <Command.RVCTCYGWIN>\r
+    <Command.RVCTCYGWIN, Command.ARMGCC>\r
         # $(OBJECT_FILES_LIST) has wrong paths for cygwin\r
         "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)\r
 \r
         "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)\r
         "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}\r
 \r
+    <Command.ARMGCC>\r
+        "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -) $(DLINK2_FLAGS)\r
+\r
     <Command.RVCT>\r
         "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)\r
 \r
     <Command.GCC>\r
         "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)\r
 \r
+    <Command.ARMGCC>\r
+        "$(DLINK)" $(DLINK_FLAGS) -( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -) $(DLINK2_FLAGS)\r
+\r
     <Command.RVCT>\r
         "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)\r
 \r
     <OutputFile>\r
         $(DEBUG_DIR)(+)$(MODULE_NAME).efi\r
 \r
-    <Command.MSFT, Command.INTEL, Command.RVCT>  \r
+    <Command.MSFT, Command.INTEL, Command.RVCT, Command.ARMGCC>  \r
         GenFw -e $(MODULE_TYPE) -o ${dst} ${src}\r
         $(CP) ${dst} $(OUTPUT_DIR)\r
         $(CP) ${dst} $(BIN_DIR)\r
index 3a604e5..419b16d 100644 (file)
@@ -140,8 +140,8 @@ DEFINE IPHONE_TOOLS            = /Developer/Platforms/iPhoneOS.platform/Develope
 DEFINE RVCT31_TOOLS_PATH       = c:/Program Files/ARM/RVCT/Programs/3.1/569/win_32-pentium\r
 DEFINE RVCT31CYGWIN_TOOLS_PATH = /cygdrive/c/Program Files/ARM/RVCT/Programs/3.1/569/win_32-pentium\r
 \r
-# Update to the location of the gcc executables\r
-DEFINE ARMGCC_BIN              = /\r
+DEFINE SOURCERY_TOOLS        = c:/Program Files/CodeSourcery/Sourcery G++ Lite/bin\r
+DEFINE SOURCERY_CYGWIN_TOOLS = /cygdrive/c/Program Files/CodeSourcery/Sourcery G++ Lite/bin\r
 \r
 ####################################################################################\r
 #\r
@@ -2838,13 +2838,16 @@ RELEASE_RVCT31CYGWIN_ARM_CC_FLAGS  = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM
 \r
 ####################################################################################\r
 #\r
-# ARM GCC (GCC 4.1.1, etc.)\r
+# ARM GCC (www.codesourcery.com)\r
 #\r
 ####################################################################################\r
 #  ARMGCC         - ARM version of the GCC cross compiler\r
 \r
 *_ARMGCC_*_*_FAMILY          = GCC\r
-*_ARMGCC_*_MAKE_PATH         = make\r
+*_ARMGCC_*_*_BUILDRULEFAMILY = ARMGCC\r
+\r
+*_ARMGCC_*_MAKE_PATH         = DEF(SOURCERY_TOOLS)/cs-make\r
+*_ARMGCC_*_MAKE_FLAGS        = --no-print-directory\r
 \r
 ##################\r
 # ASL definitions\r
@@ -2860,24 +2863,24 @@ RELEASE_RVCT31CYGWIN_ARM_CC_FLAGS  = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM
 # ARM definitions\r
 ##################\r
 \r
-*_ARMGCC_ARM_ASLCC_PATH      = DEF(ARMGCC_BIN)/arm-elf-gcc\r
-*_ARMGCC_ARM_ASLDLINK_PATH   = DEF(ARMGCC_BIN)/arm-elf-ld\r
-*_ARMGCC_ARM_ASLPP_PATH      = DEF(ARMGCC_BIN)/arm-elf-gcc\r
+*_ARMGCC_ARM_ASLCC_PATH      = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc\r
+*_ARMGCC_ARM_ASLDLINK_PATH   = DEF(SOURCERY_TOOLS)/arm-none-eabi-ld\r
+*_ARMGCC_ARM_ASLPP_PATH      = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc\r
 \r
-*_ARMGCC_ARM_CC_PATH         = DEF(ARMGCC_BIN)/arm-elf-gcc\r
-*_ARMGCC_ARM_SLINK_PATH      = DEF(ARMGCC_BIN)/arm-elf-ar\r
-*_ARMGCC_ARM_DLINK_PATH      = DEF(ARMGCC_BIN)/arm-elf-ld\r
-*_ARMGCC_ARM_ASM_PATH        = DEF(ARMGCC_BIN)/arm-elf-as\r
-*_ARMGCC_ARM_PP_PATH         = DEF(ARMGCC_BIN)/arm-elf-gcc\r
-*_ARMGCC_ARM_VFRPP_PATH      = DEF(ARMGCC_BIN)/arm-elf-gcc\r
+*_ARMGCC_ARM_CC_PATH         = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc\r
+*_ARMGCC_ARM_SLINK_PATH      = DEF(SOURCERY_TOOLS)/arm-none-eabi-ar\r
+*_ARMGCC_ARM_DLINK_PATH      = DEF(SOURCERY_TOOLS)/arm-none-eabi-ld\r
+*_ARMGCC_ARM_ASM_PATH        = DEF(SOURCERY_TOOLS)/arm-none-eabi-as\r
+*_ARMGCC_ARM_PP_PATH         = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc\r
+*_ARMGCC_ARM_VFRPP_PATH      = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc\r
 \r
 #\r
 # Use default values, or override in DSC file\r
 #\r
-*_ARMGCC_ARM_ARCHCC_FLAGS    = \r
-*_ARMGCC_ARM_ARCHASM_FLAGS   = \r
+*_ARMGCC_ARM_ARCHCC_FLAGS    = -march=armv7-a -mthumb \r
+*_ARMGCC_ARM_ARCHASM_FLAGS   = -march=armv7-a\r
 *_ARMGCC_ARM_ARCHDLINK_FLAGS = \r
-*_ARMGCC_ARM_PLATFORM_FLAGS  =\r
+*_ARMGCC_ARM_PLATFORM_FLAGS  = -march=armv7-a\r
 \r
   DEBUG_ARMGCC_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) -mlittle-endian -g\r
 RELEASE_ARMGCC_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) -mlittle-endian\r
@@ -2885,11 +2888,12 @@ RELEASE_ARMGCC_ARM_ASM_FLAGS   = $(ARCHASM_FLAGS) -mlittle-endian
 *_ARMGCC_ARM_PP_FLAGS    = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS)  -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
 *_ARMGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS)  -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h\r
 \r
-*_ARMGCC_ARM_MAKE_PATH   = make\r
-\r
-*_ARMGCC_ARM_SLINK_FLAGS = -r\r
-*_ARMGCC_ARM_DLINK_FLAGS =  $(ARCHDLINK_FLAGS) --emit-relocs --oformat=elf32-littlearm -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map\r
-# --gc-sections\r
+*_ARMGCC_ARM_SLINK_FLAGS =  -rc\r
+*_ARMGCC_ARM_DLINK_FLAGS =  $(ARCHDLINK_FLAGS)  --oformat=elf32-littlearm -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map\r
+#\r
+# Had to remove --emit-relocs to get compile working. Images don't work correctly (linked at 0, no relocations)\r
+# --emit-relocs\r
+#\r
 \r
   DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian -g -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h\r
 RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian    -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h\r
index e609f93..414851a 100644 (file)
@@ -1143,6 +1143,7 @@ WriteRelocations(
   UINT8                            *Targ;\r
   Elf32_Phdr                       *DynamicSegment;\r
   Elf32_Phdr                       *TargetSegment;\r
+  static int                       ErrorCount = 0;\r
 \r
   for (Index = 0, FoundRelocations = FALSE; Index < Ehdr->e_shnum; Index++) {\r
     Elf_Shdr *RelShdr = GetShdrByIndex(Index);\r
@@ -1166,7 +1167,7 @@ WriteRelocations(
               EFI_IMAGE_REL_BASED_HIGHLOW);\r
               break;\r
             default:\r
-              Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));\r
+              Error (NULL, 0, 3000, "Invalid", "%s unkown relocation %x.", mInImageName, (unsigned) ELF_R_TYPE(Rel->r_info));\r
             }\r
           } else if (Ehdr->e_machine == EM_ARM) {\r
             switch (ELF32_R_TYPE(Rel->r_info)) {\r
@@ -1182,8 +1183,17 @@ WriteRelocations(
                 EFI_IMAGE_REL_BASED_HIGHLOW\r
                 );\r
               break;\r
+              \r
+            case R_ARM_CALL:\r
+            case R_ARM_THM_MOVW_ABS_NC:\r
+            case R_ARM_THM_MOVT_ABS:\r
+              if (ErrorCount++ == 0) {\r
+                Error (NULL, 0, 3000, "Invalid", "www.codesourcery.com ELF relocations not yet implemented!!!! Bad Image", mInImageName);\r
+              }\r
+              break;\r
+\r
             default:\r
-              Error (NULL, 0, 3000, "Invalid", "%s unhandled section type %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));\r
+              Error (NULL, 0, 3000, "Invalid", "%s unkown relocation %x.", mInImageName, (unsigned) ELF32_R_TYPE(Rel->r_info));\r
             }\r
           } else {\r
             Error (NULL, 0, 3000, "Not Supported", "This tool does not support relocations for ELF with e_machine %u (processor type).", (unsigned) Ehdr->e_machine);\r
index 1cd3f53..ed99bbc 100644 (file)
@@ -597,6 +597,11 @@ typedef struct {
 #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_GNU_VTENTRY       100
 #define        R_ARM_GNU_VTINHERIT     101
 #define        R_ARM_RSBREL32          250