mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-07-17 18:43:25 +08:00
* embedspu.sh: Combine "_EAR_" and "_EAR_*" patterns. Tighten
.toe section and .toe address checks. Use .reloc for _EAR* symbols defined in non-BSS sections. Build table for _SPUEAR_ symbols.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2007-03-27 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* embedspu.sh: Combine "_EAR_" and "_EAR_*" patterns. Tighten
|
||||||
|
.toe section and .toe address checks. Use .reloc for _EAR*
|
||||||
|
symbols defined in non-BSS sections. Build table for _SPUEAR_
|
||||||
|
symbols.
|
||||||
|
|
||||||
2007-03-23 Kaz Kojima <kkojima@rr.iij4u.or.jp>
|
2007-03-23 Kaz Kojima <kkojima@rr.iij4u.or.jp>
|
||||||
|
|
||||||
PR gas/3811
|
PR gas/3811
|
||||||
|
@ -116,18 +116,27 @@ main ()
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
toe=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *\.toe *[PROGN]*BITS *\([0-9a-f]*\).*,\1 \2,p'`
|
||||||
|
toe_addr=`echo $toe | sed -n -e 's,.* ,,p'`
|
||||||
|
toe=`echo $toe | sed -n -e 's, .*,,p'`
|
||||||
|
sections=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *[^ ]* *PROGBITS *\([0-9a-f]*\) *\([0-9a-f]*\).*,\1 \2 \3,p'`
|
||||||
|
sections=`echo ${sections}`
|
||||||
|
|
||||||
# Build embedded SPU image.
|
# Build embedded SPU image.
|
||||||
# 1. The whole SPU ELF file is written to .rodata.speelf
|
# 1. The whole SPU ELF file is written to .rodata.speelf
|
||||||
# 2. Symbols starting with the string "_EAR_" in the SPU ELF image are
|
# 2. Symbols starting with the string "_EAR_" in the SPU ELF image are
|
||||||
# special. They allow an SPU program to access corresponding symbols
|
# special. They allow an SPU program to access corresponding symbols
|
||||||
# (ie. minus the _EAR_ prefix), in the PowerPC program. _EAR_ without
|
# (ie. minus the _EAR_ prefix), in the PowerPC program. _EAR_ without
|
||||||
# a suffix is used to refer to the addrress of the SPU image in
|
# a suffix is used to refer to the addrress of the SPU image in
|
||||||
# PowerPC address space. _EAR_* symbols must all be defined in one
|
# PowerPC address space. _EAR_* symbols must all be defined in .toe
|
||||||
# section at 16 byte intervals.
|
# at 16 byte intervals, or they must be defined in other non-bss
|
||||||
# Find all _EAR_ symbols using readelf, sort by address, and write
|
# sections.
|
||||||
# the address of the corresponding PowerPC symbol in a table built
|
# Find all _EAR_ symbols in .toe using readelf, sort by address, and
|
||||||
# in .data.spetoe.
|
# write the address of the corresponding PowerPC symbol in a table
|
||||||
|
# built in .data.spetoe. For _EAE_ symbols not in .toe, create
|
||||||
|
# .reloc commands to relocate their location directly.
|
||||||
# 3. Write a struct spe_program_handle to .data.
|
# 3. Write a struct spe_program_handle to .data.
|
||||||
|
# 4. Write a table of _SPUEAR_ symbols.
|
||||||
${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \
|
${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \
|
||||||
-Wa,-mbig -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
|
-Wa,-mbig -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
|
||||||
.section .rodata.speelf,"a",@progbits
|
.section .rodata.speelf,"a",@progbits
|
||||||
@ -140,29 +149,36 @@ __speelf__:
|
|||||||
__spetoe__:
|
__spetoe__:
|
||||||
`${READELF} -s -W ${INFILE} | grep ' _EAR_' | sort -k 2 | awk \
|
`${READELF} -s -W ${INFILE} | grep ' _EAR_' | sort -k 2 | awk \
|
||||||
'BEGIN { \
|
'BEGIN { \
|
||||||
last_addr = 0; \
|
addr = strtonum ("0x" '${toe_addr-0}'); \
|
||||||
last_sym = ""; \
|
split ("'"${sections}"'", s, " "); \
|
||||||
|
for (i = 1; i in s; i += 3) { \
|
||||||
|
sec_off[s[i]] = strtonum ("0x" s[i+2]) - strtonum ("0x" s[i+1]); \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
last_addr != 0 && strtonum("0x" $2) != last_addr + 16 { \
|
$7 == "'${toe}'" && strtonum ("0x" $2) != addr { \
|
||||||
print "#error Symbols " last_sym " and " $8 " are not 16 bytes apart!"; \
|
print "#error Symbol " $8 " not in 16 byte element toe array!"; \
|
||||||
} \
|
} \
|
||||||
{ last_addr = strtonum("0x" $2); \
|
$7 == "'${toe}'" { \
|
||||||
last_sym = $8; \
|
addr = addr + 16; \
|
||||||
} \
|
} \
|
||||||
$8 == "_EAR_" { \
|
$7 == "'${toe}'" { \
|
||||||
print "#ifdef _LP64"; \
|
print "#ifdef _LP64"; \
|
||||||
print " .quad __speelf__, 0"; \
|
print " .quad " ($8 == "_EAR_" ? "__speelf__" : substr($8, 6)) ", 0"; \
|
||||||
print "#else"; \
|
print "#else"; \
|
||||||
print " .int 0, __speelf__, 0, 0"; \
|
print " .int 0, " ($8 == "_EAR_" ? "__speelf__" : substr($8, 6)) ", 0, 0"; \
|
||||||
print "#endif"; \
|
print "#endif"; \
|
||||||
} \
|
} \
|
||||||
$8 != "_EAR_" { \
|
$7 != "'${toe}'" && $7 in sec_off { \
|
||||||
print "#ifdef _LP64"; \
|
print "#ifdef _LP64"; \
|
||||||
print " .quad " substr($8, 6) ", 0"; \
|
print " .reloc __speelf__+" strtonum ("0x" $2) + sec_off[$7] ", R_PPC64_ADDR64, " ($8 == "_EAR_" ? "__speelf__" : substr($8, 6)); \
|
||||||
print "#else"; \
|
print "#else"; \
|
||||||
print " .int 0, " substr($8, 6) ", 0, 0"; \
|
print " .reloc __speelf__+" strtonum ("0x" $2) + sec_off[$7] + 4 ", R_PPC_ADDR32, " ($8 == "_EAR_" ? "__speelf__" : substr($8, 6)); \
|
||||||
print "#endif"; \
|
print "#endif"; \
|
||||||
}'`
|
} \
|
||||||
|
$7 != "'${toe}'" && ! $7 in sec_off { \
|
||||||
|
print "#error Section not found for " $8; \
|
||||||
|
} \
|
||||||
|
'`
|
||||||
|
|
||||||
.section .data,"aw",@progbits
|
.section .data,"aw",@progbits
|
||||||
.globl ${SYMBOL}
|
.globl ${SYMBOL}
|
||||||
@ -183,6 +199,16 @@ ${SYMBOL}:
|
|||||||
.int __spetoe__
|
.int __spetoe__
|
||||||
#endif
|
#endif
|
||||||
.size ${SYMBOL}, . - ${SYMBOL}
|
.size ${SYMBOL}, . - ${SYMBOL}
|
||||||
|
|
||||||
|
`${READELF} -s -W ${INFILE} | grep ' _SPUEAR_' | sort -k 2 | awk \
|
||||||
|
'{ \
|
||||||
|
print " .globl '${SYMBOL}'_" substr($8, 9); \
|
||||||
|
print " .type '${SYMBOL}'_" substr($8, 9) ", @object"; \
|
||||||
|
print " .size '${SYMBOL}'_" substr($8, 9) ", 4"; \
|
||||||
|
print "'${SYMBOL}'_" substr($8, 9) ":"; \
|
||||||
|
print " .int " $2; \
|
||||||
|
} \
|
||||||
|
'`
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user