Fix various Makefile and ldscript issues
1) Compile all the C files using the same compiler options Some C files were compiled in the recipe to link the final .elf, while the others were compiled using make implicit rules. This caused all the .o files specified in the OBJS variable to be compiled without the -fno-zero-initialized-in-bss option, potentially leading to the use of uninitialized memory. This commit puts all the C-compiler-specific options in the CFLAGS variable, as well as clearly separating the compilation and linking phases, relying on implicit make rules for the compilation part. 2) Explcitly put the output of m4_start.S first in the output .elf The .text section of m4_start.o was output at the lowest address only because the file was placed first in the OBJS variable. This commit changes the ldscript to always place the .text section of m4_start.o first in the output, no matter the order of the input files on the command line. 3) Move all data in .bss sections into the .data section Since the final .elf is linked with -nostartfiles, the .bss section is not initialized, causing code expecting data to be initialized to 0 to use uninitialized memory. This commit changes the ldscript to put the common symbols, which were previously put in the .bss section, in the .data section to ensure the data is initialized. This has the side-effect of allocating the space for that data in the binary, increasing its size by 54 bytes. 4) Group all common linker options in the LDFLAGS variable Most linker options were duplicated in the recipes for m4_tcm.elf and m4_ocram.elf. This commit puts all the common linker options in the LDFLAGS variable for the sake of clarity, in addition to other minor cosmetic changes.
Showing with 22 additions and 17 deletions