ElfLinker::addSection ==> addLoader
This commit is contained in:
+14
-28
@@ -126,6 +126,8 @@ override T = $(basename $(notdir $@))
|
||||
# // setup toolchain globals
|
||||
# ************************************************************************/
|
||||
|
||||
RTRIM := sed -e 's/[ ]*$$//'
|
||||
|
||||
# default settings for $(tc_list)
|
||||
tc.default.bin2h = python $(top_srcdir)/src/stub/scripts/bin2h.py
|
||||
tc.default.brandelf = python $(top_srcdir)/src/stub/scripts/brandelf.py $(if $(tc_bfdname),--bfdname=$(tc_bfdname))
|
||||
@@ -139,7 +141,7 @@ tc.default.sstrip = sstrip
|
||||
tc.default.m-ld = multiarch-ld-2.17 $(if $(tc_bfdname),-b $(tc_bfdname))
|
||||
tc.default.m-nm = multiarch-nm-2.17 $(if $(tc_bfdname),--target=$(tc_bfdname))
|
||||
tc.default.m-objcopy = multiarch-objcopy-2.17 $(if $(tc_bfdname),-F $(tc_bfdname))
|
||||
tc.default.m-objdump = multiarch-objdump-2.17 $(if $(tc_bfdname),-b $(tc_bfdname))
|
||||
tc.default.m-objdump = multiarch-objdump-2.17 $(if $(tc_bfdname),-b $(tc_bfdname)) $(if $(tc_bfdarch),-m $(tc_bfdarch))
|
||||
tc.default.m-readelf = multiarch-readelf-2.17
|
||||
|
||||
# default binutils
|
||||
@@ -150,10 +152,11 @@ tc.default.objdump = $(call tc,m-objdump)
|
||||
tc.default.objstrip = $(call tc,objcopy) -R .comment -R .note -R .reginfo
|
||||
|
||||
define tc.default.embed_objinfo
|
||||
$(call tc,m-objdump) -D $2 | $(RTRIM) > $2.disasm
|
||||
$(call tc,m-objcopy) --strip-unneeded $2
|
||||
$(call tc,m-objcopy) -R .text -R .data -R .bss $2
|
||||
$(call tc,m-objcopy) -R .comment -R .note -R .reginfo $2
|
||||
$(call tc,m-objdump) -trwh $2 | sed -e 's/[ ]*$$//' > $2.dump
|
||||
$(call tc,m-objdump) -trwh $2 | $(RTRIM) > $2.dump
|
||||
cat $2.dump >> $2
|
||||
endef
|
||||
|
||||
@@ -181,6 +184,7 @@ PP_FLAGS =
|
||||
IDENT_NAME =
|
||||
IDENT_PREFIX =
|
||||
IDENT_SUFFIX =
|
||||
tc_bfdarch =
|
||||
tc_bfdname =
|
||||
tc_list =
|
||||
|
||||
@@ -222,7 +226,7 @@ tmp/amd64-linux.elf-main.o : $(srcdir)/src/$$T.c
|
||||
arm-linux.elf% : tc_list = arm-linux.elf default
|
||||
arm-linux.elf% : tc_bfdname = elf32-littlearm
|
||||
|
||||
tc.arm-linux.elf.gcc = arm-linux-gcc-4.1.0 -march=armv4 -nostdinc -MMD -MT $@
|
||||
tc.arm-linux.elf.gcc = arm-linux-gcc-4.1.0 -mlittle-endian -march=armv4 -nostdinc -MMD -MT $@
|
||||
tc.arm-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
|
||||
tc.arm-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
|
||||
|
||||
@@ -265,26 +269,12 @@ arm.v4t-wince.pe% : tc_bfdname = elf32-littlearm
|
||||
|
||||
arm.v4a-wince.pe.h : $(srcdir)/src/$$T.S
|
||||
$(call tc,gcc) -march=armv4 -c $< -o tmp/$T.bin
|
||||
ifeq (1,1)
|
||||
$(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin
|
||||
$(call tc,m-objcopy) -R .note -R .comment tmp/$T.bin
|
||||
$(call tc,m-objdump) -trwh tmp/$T.bin >> tmp/$T.bin
|
||||
else
|
||||
# FIXME: can we use --strip-unneeded on arm ??
|
||||
$(call tc,embed_objinfo,tmp/$T.bin)
|
||||
endif
|
||||
$(call tc,bin2h) --ident=nrv_loader_arm tmp/$T.bin $@
|
||||
|
||||
arm.v4t-wince.pe.h : $(srcdir)/src/$$T.S
|
||||
$(call tc,gcc) -march=armv4t -c $< -o tmp/$T.bin
|
||||
ifeq (1,1)
|
||||
$(call tc,m-objcopy) -R .text -R .data -R .bss tmp/$T.bin
|
||||
$(call tc,m-objcopy) -R .note -R .comment tmp/$T.bin
|
||||
$(call tc,m-objdump) -trwh tmp/$T.bin >> tmp/$T.bin
|
||||
else
|
||||
# FIXME: can we use --strip-unneeded on arm ??
|
||||
$(call tc,embed_objinfo,tmp/$T.bin)
|
||||
endif
|
||||
$(call tc,bin2h) --ident=nrv_loader_thumb tmp/$T.bin $@
|
||||
|
||||
|
||||
@@ -293,6 +283,7 @@ endif
|
||||
# ************************************************************************/
|
||||
|
||||
i086-dos16.com% : tc_list = arch-i086 default
|
||||
i086-dos16.com% : tc_bfdarch = i8086
|
||||
|
||||
i086-dos16.com.h : $(srcdir)/src/$$T.S
|
||||
$(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin
|
||||
@@ -305,6 +296,7 @@ i086-dos16.com.h : $(srcdir)/src/$$T.S
|
||||
# ************************************************************************/
|
||||
|
||||
i086-dos16.exe% : tc_list = arch-i086 default
|
||||
i086-dos16.exe% : tc_bfdarch = i8086
|
||||
|
||||
i086-dos16.exe.h : $(srcdir)/src/$$T.S
|
||||
$(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin
|
||||
@@ -317,6 +309,7 @@ i086-dos16.exe.h : $(srcdir)/src/$$T.S
|
||||
# ************************************************************************/
|
||||
|
||||
i086-dos16.sys% : tc_list = arch-i086 default
|
||||
i086-dos16.sys% : tc_bfdarch = i8086
|
||||
|
||||
i086-dos16.sys.h : $(srcdir)/src/$$T.S
|
||||
$(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin
|
||||
@@ -606,19 +599,12 @@ i386-win32.pe.h : $(srcdir)/src/$$T.S
|
||||
m68k-atari.tos-%.h : tc_list = m68k-atari.tos default
|
||||
m68k-atari.tos-%.h : tc_bfdname = elf32-m68k
|
||||
|
||||
tc.m68k-atari.tos.as = m68k-linux-as-20060406 --register-prefix-optional
|
||||
tc.m68k-atari.tos.gcc = m68k-linux-gcc-4.1.1 -nostdinc -MMD -MT $@
|
||||
tc.m68k-atari.tos.gcc = m68k-linux-gcc-4.1.1 -m68000 -malign-int -nostdinc -MMD -MT $@
|
||||
tc.m68k-atari.tos.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
|
||||
tc.m68k-atari.tos.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
|
||||
|
||||
m68k-atari.tos-nrv%.h : $(srcdir)/src/m68k-atari.tos.S
|
||||
ifeq (1,2)
|
||||
$(call tc,pp-as) -D__GAS__ $(PP_FLAGS) $< -o tmp/$T.i
|
||||
$(call tc,as) tmp/$T.i -o tmp/$T.bin
|
||||
$(call tc,gpp_mkdep) --mode=c --MMD=$@ $< --MF=tmp/$T.d
|
||||
else
|
||||
$(call tc,gcc) -c -D__GAS__ $(PP_FLAGS) -x assembler-with-cpp -Wa,--register-prefix-optional $< -o tmp/$T.bin
|
||||
endif
|
||||
$(call tc,embed_objinfo,tmp/$T.bin)
|
||||
$(call tc,bin2h) --ident=$(IDENT_PREFIX)loader$(IDENT_SUFFIX) tmp/$T.bin $@
|
||||
|
||||
@@ -647,8 +633,8 @@ tc.mipsel.r3000-ps1.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -We
|
||||
|
||||
mipsel.r3000-ps1.h : $(srcdir)/src/$$T.S
|
||||
ifeq (1,1)
|
||||
$(call tc,pp-as) $(PP_FLAGS) $< -o tmp/$T.tmp1
|
||||
$(call tc,as) tmp/$T.tmp1 -o tmp/$T.bin
|
||||
$(call tc,pp-as) $(PP_FLAGS) $< -o tmp/$T.i
|
||||
$(call tc,as) tmp/$T.i -o tmp/$T.bin
|
||||
$(call tc,gpp_mkdep) --mode=c --MMD=$@ $< --MF=tmp/$T.d
|
||||
else
|
||||
## FIXME - as-2.16.1 does not work ???
|
||||
@@ -694,7 +680,7 @@ tmp/powerpc-darwin.macho-main.o : $(srcdir)/src/$$T.c
|
||||
powerpc-linux.elf% : tc_list = powerpc-linux.elf default
|
||||
powerpc-linux.elf% : tc_bfdname = elf32-powerpc
|
||||
|
||||
tc.powerpc-linux.elf.gcc = powerpc.405-linux-gcc-3.4.5 -mcpu=405 -nostdinc -MMD -MT $@
|
||||
tc.powerpc-linux.elf.gcc = powerpc.405-linux-gcc-3.4.5 -m32 -mbig-endian -mcpu=405 -nostdinc -MMD -MT $@
|
||||
tc.powerpc-linux.elf.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
|
||||
tc.powerpc-linux.elf.gcc += -Wall -W -Wcast-align -Wcast-qual -Wwrite-strings -Werror
|
||||
|
||||
|
||||
+909
-1132
File diff suppressed because it is too large
Load Diff
+386
-582
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@ lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,objstrip) tmp/$T.o
|
||||
$(call tc,objcopy) -O binary --only-section .text.LzmaDecode tmp/$T.o tmp/$T.bin
|
||||
head -c-1 tmp/$T.bin > tmp/$T.out
|
||||
$(call tc,objdump) -b binary -m i386:x86-64 -D tmp/$T.out > tmp/$T.out.lst
|
||||
$(call tc,objdump) -b binary -m i386:x86-64 -D tmp/$T.out | $(RTRIM) > tmp/$T.out.disasm
|
||||
$(call tc,bin2h) --mode=gas tmp/$T.out $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
|
||||
@@ -37,7 +37,7 @@ tc.arm-lzma.gcc += -I$(top_srcdir)/src
|
||||
|
||||
lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/$(LABEL_PREFIX)/g' < tmp/$T.s > $@
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/$(LABEL_PREFIX)/g' tmp/$T.s | $(RTRIM) > $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
lzma_d_cs.% : PP_FLAGS = -DSMALL
|
||||
|
||||
@@ -35,7 +35,7 @@ tc.arm-lzma.gcc += -I$(top_srcdir)/src
|
||||
|
||||
lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,gcc) $(PP_FLAGS) -S $< -o tmp/$T.s
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/$(LABEL_PREFIX)/g' < tmp/$T.s > $@
|
||||
sed -e '1,/LzmaDecode:/d' -e '/\.size/d' -e '/\.ident/d' -e 's/\.L/$(LABEL_PREFIX)/g' tmp/$T.s | $(RTRIM) > $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
lzma_d_cs.% : PP_FLAGS = -DSMALL
|
||||
|
||||
@@ -36,7 +36,7 @@ lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,objstrip) tmp/$T.o
|
||||
$(call tc,objcopy) -O binary --only-section .text.LzmaDecode tmp/$T.o tmp/$T.bin
|
||||
head -c-1 tmp/$T.bin > tmp/$T.out
|
||||
$(call tc,objdump) -b binary -m i386 -D tmp/$T.out > tmp/$T.out.lst
|
||||
$(call tc,objdump) -b binary -m i386 -D tmp/$T.out | $(RTRIM) > tmp/$T.out.disasm
|
||||
$(call tc,bin2h) --mode=gas tmp/$T.out $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
|
||||
@@ -38,7 +38,7 @@ lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,objstrip) tmp/$T.o
|
||||
$(call tc,m-objcopy) -O binary --only-section .text.LzmaDecode tmp/$T.o tmp/$T.bin
|
||||
head -c-0 tmp/$T.bin > tmp/$T.out
|
||||
$(call tc,m-objdump) -b binary -m mips:3000 -D tmp/$T.out > tmp/$T.out.lst
|
||||
$(call tc,m-objdump) -b binary -m mips:3000 -D tmp/$T.out | $(RTRIM) > tmp/$T.out.disasm
|
||||
$(call tc,bin2h) --mode=gas tmp/$T.out $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
|
||||
@@ -38,7 +38,7 @@ lzma_d_c%.S : lzma_d_c.c
|
||||
$(call tc,objstrip) tmp/$T.o
|
||||
$(call tc,objcopy) -O binary --only-section .text.LzmaDecode tmp/$T.o tmp/$T.bin
|
||||
head -c-4 tmp/$T.bin > tmp/$T.out
|
||||
$(call tc,objdump) -b binary -m powerpc -D tmp/$T.out > tmp/$T.out.lst
|
||||
$(call tc,objdump) -b binary -m powerpc -D tmp/$T.out | $(RTRIM) > tmp/$T.out.disasm
|
||||
$(call tc,bin2h) --mode=gas tmp/$T.out $@
|
||||
|
||||
lzma_d_cf.% : PP_FLAGS = -DFAST
|
||||
|
||||
@@ -55,6 +55,18 @@
|
||||
|
||||
#define section .section
|
||||
|
||||
// p_armpe.cpp uses the following symbols, so they should be global
|
||||
|
||||
.globl SRC0
|
||||
.globl DST0
|
||||
.globl IATT
|
||||
.globl ENTR
|
||||
.globl FIBS
|
||||
.globl FIBE
|
||||
.globl BREL
|
||||
.globl BIMP
|
||||
.globl ONAM
|
||||
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
.arm
|
||||
|
||||
@@ -29,6 +29,11 @@
|
||||
<jreiser@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
// p_armpe.cpp uses some symbols, so they should be global
|
||||
// in thumb mode we need this S() macro hack to export a symbol which
|
||||
// is used in an ldr statement
|
||||
#define S(sym) .globl sym; sym: .L##sym
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
#define section .section
|
||||
@@ -65,12 +70,12 @@ section ExeStart
|
||||
ldr ip, ENTR
|
||||
bx ip
|
||||
|
||||
SRC0: .long start_of_compressed
|
||||
S(SRC0):.long start_of_compressed
|
||||
SRCL: .long compressed_length
|
||||
DST0: .long start_of_uncompressed
|
||||
S(DST0):.long start_of_uncompressed
|
||||
DSTL: .long uncompressed_length
|
||||
IATT: .long 0, 0, 0, 0
|
||||
ENTR: .long original_entry
|
||||
S(IATT):.long 0, 0, 0, 0
|
||||
S(ENTR):.long original_entry
|
||||
|
||||
.thumb
|
||||
|
||||
@@ -89,9 +94,9 @@ section Unfilter_0x50
|
||||
addval .req r2
|
||||
bufend .req r4
|
||||
|
||||
ldr buffer, FIBS
|
||||
ldr buffer, .LFIBS
|
||||
mov addval, #0
|
||||
ldr bufend, FIBE
|
||||
ldr bufend, .LFIBE
|
||||
mov r5, #0x0f
|
||||
mov r6, #0xff
|
||||
lsl r6, #24
|
||||
@@ -122,8 +127,8 @@ section Unfilter_0x50
|
||||
.unreq bufend
|
||||
|
||||
.align 2
|
||||
FIBS: .long filter_buffer_start
|
||||
FIBE: .long filter_buffer_end
|
||||
S(FIBS):.long filter_buffer_start
|
||||
S(FIBE):.long filter_buffer_end
|
||||
|
||||
.Luf50_ret:
|
||||
|
||||
@@ -134,7 +139,7 @@ section Relocs
|
||||
dest .req r1
|
||||
addval .req r2
|
||||
|
||||
ldr buffer, BREL
|
||||
ldr buffer, .LBREL
|
||||
mov addval, dst0
|
||||
sub dest, addval, #4
|
||||
|
||||
@@ -173,7 +178,7 @@ section Relocs
|
||||
b .Lreloc_loop
|
||||
|
||||
.align 2
|
||||
BREL: .long start_of_relocs
|
||||
S(BREL):.long start_of_relocs
|
||||
|
||||
.Lreloc_end:
|
||||
|
||||
@@ -190,13 +195,13 @@ section Imports
|
||||
sub sp, #508
|
||||
sub sp, #508
|
||||
sub sp, #508
|
||||
ldr imp, BIMP
|
||||
ldr imp, .LBIMP
|
||||
.Lhi_loop1:
|
||||
mov r0, imp
|
||||
bl get_le32
|
||||
beq .Lhi_end
|
||||
|
||||
ldr r1, ONAM
|
||||
ldr r1, .LONAM
|
||||
add r0, r1
|
||||
mov r1, sp
|
||||
.Lhi_copyname:
|
||||
@@ -265,8 +270,8 @@ LoadLibraryW:
|
||||
GetProcAddressA:
|
||||
bx r11
|
||||
|
||||
BIMP: .long start_of_imports
|
||||
ONAM: .long start_of_dll_names
|
||||
S(BIMP):.long start_of_imports
|
||||
S(ONAM):.long start_of_dll_names
|
||||
|
||||
.Lhi_end:
|
||||
mov sp, r7
|
||||
|
||||
Reference in New Issue
Block a user