aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2007-05-11 03:10:11 +0000
committerAlan Modra <amodra@gmail.com>2007-05-11 03:10:11 +0000
commitece5ef60797fafabe50aae16758ecb33b033871d (patch)
tree89aad076c5b14d568aec538ccf07e4d080b94443 /binutils
parent88b131f3cecc522396bf5c83c09ff76476ad56b9 (diff)
downloadgdb-ece5ef60797fafabe50aae16758ecb33b033871d.zip
gdb-ece5ef60797fafabe50aae16758ecb33b033871d.tar.gz
gdb-ece5ef60797fafabe50aae16758ecb33b033871d.tar.bz2
include/elf/
* spu.h (R_SPU_PPU32, R_SPU_PPU64): Define. bfd/ * reloc.c (BFD_RELOC_SPU_PPU32, BFD_RELOC_SPU_PPU64): Define. * elf-bfd.h (struct elf_backend_data): Change return type of elf_backend_relocate_section to int. * elf32-spu.c (elf_howto_table): Add howtos for R_SPU_PPU32 and R_SPU_PPU64. (spu_elf_bfd_to_reloc_type): Convert new relocs. (spu_elf_count_relocs): New function. (elf_backend_count_relocs): Define. (spu_elf_relocate_section): Arrange to emit R_SPU_PPU32 and R_SPU_PPU64 relocs. * elflink.c (elf_link_input_bfd): Emit relocs if relocate_section returns 2. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. gas/ * config/tc-spu.c (md_pseudo_table): Add int, long, quad. Call spu_cons for word. (md_assemble): Tidy use of insn.flag. (get_imm): Likewise. Handle uppercase input too. (spu_cons): New function. * config/tc-spu.h (tc_fix_adjustable): Don't adjust SPU_PPU relocs. (TC_FORCE_RELOCATION): Don't resolve them either. binutils/ * embedspu.sh (find_prog): Prefer prog in same dir as embedspu over one found on the users path. (main): Generate .reloc for each R_SPU_PPU* reloc.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog6
-rw-r--r--binutils/embedspu.sh44
2 files changed, 46 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8e68263..f5f0b58 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-11 Alan Modra <amodra@bigpond.net.au>
+
+ * embedspu.sh (find_prog): Prefer prog in same dir as embedspu
+ over one found on the users path.
+ (main): Generate .reloc for each R_SPU_PPU* reloc.
+
2007-04-28 Alan Modra <amodra@bigpond.net.au>
* prdbg.c (tg_variable): Adjust for changed demangler.
diff --git a/binutils/embedspu.sh b/binutils/embedspu.sh
index 3269ab8..7a32158 100644
--- a/binutils/embedspu.sh
+++ b/binutils/embedspu.sh
@@ -38,12 +38,12 @@ mydir=`dirname "$0"`
find_prog ()
{
prog=`echo $1 | sed "$program_transform_name"`
- which $prog > /dev/null 2> /dev/null && return 0
prog="$mydir/$prog"
test -x "$prog" && return 0
prog="$mydir/$1"
test -x "$prog" && return 0
prog=`echo $1 | sed "$program_transform_name"`
+ which $prog > /dev/null 2> /dev/null && return 0
return 1
}
@@ -95,7 +95,7 @@ main ()
CC="$prog"
fi
- # Find readelf. Any old readelf should do. We only want to read syms.
+ # Find readelf. Any old readelf should do.
find_prog readelf
if test $? -ne 0; then
if which readelf > /dev/null 2> /dev/null; then
@@ -119,8 +119,13 @@ main ()
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'`
+ # For loaded sections, pick off section number, address, and file offset
sections=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *\([0-9]*\)\] *[^ ]* *PROGBITS *\([0-9a-f]*\) *\([0-9a-f]*\).*,\1 \2 \3,p'`
sections=`echo ${sections}`
+ # For relocation sections, pick off file offset and info (points to
+ # section where relocs apply)
+ relas=`${READELF} -S ${INFILE} | sed -n -e 's, *\[ *[0-9]*\] *[^ ]* *RELA *[0-9a-f]* *0*\([0-9a-f][0-9a-f]*\) .*\([0-9a-f][0-9a-f]*\) *[0-9a-f][0-9a-f]*$,\1 \2,p'`
+ relas=`echo ${relas}`
# Build embedded SPU image.
# 1. The whole SPU ELF file is written to .rodata.speelf
@@ -135,8 +140,10 @@ main ()
# 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.
- # 4. Write a table of _SPUEAR_ symbols.
+ # 3. Look for R_SPU_PPU32 and R_SPU_PPU64 relocations in the SPU ELF image
+ # and create .reloc commands for them.
+ # 4. Write a struct spe_program_handle to .data.
+ # 5. Write a table of _SPUEAR_ symbols.
${CC} ${FLAGS} -x assembler-with-cpp -nostartfiles -nostdlib \
-Wa,-mbig -Wl,-r -Wl,-x -o ${OUTFILE} - <<EOF
.section .rodata.speelf,"a",@progbits
@@ -179,6 +186,35 @@ $7 != "'${toe}'" && ! $7 in sec_off { \
print "#error Section not found for " $8; \
} \
'`
+`test -z "${relas}" || ${READELF} -r -W ${INFILE} | awk \
+'BEGIN { \
+ 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]); \
+ } \
+ split ("'"${relas}"'", s, " "); \
+ for (i = 1; i in s; i += 2) { \
+ rela[s[i]] = strtonum (s[i+1]); \
+ } \
+} \
+/^Relocation section/ { \
+ sec = substr($6, 3); \
+} \
+$3 ~ /R_SPU_PPU/ { \
+ print "#ifdef _LP64"; \
+ print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" substr($3, 10) ", " $5 "+0x" $7; \
+ print "#else"; \
+ print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + (substr($3, 10) == "64" ? 4 : 0)", R_PPC_ADDR32, " $5 "+0x" $7; \
+ print "#endif"; \
+} \
+$3 ~ /unrecognized:/ { \
+ print "#ifdef _LP64"; \
+ print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] ", R_PPC64_ADDR" ($4 == "f" ? "64" : "32") ", " $6 "+0x" $8; \
+ print "#else"; \
+ print " .reloc __speelf__+" strtonum ("0x" $1) + sec_off[rela[sec]] + ($4 == "f" ? 4 : 0)", R_PPC_ADDR32, " $6 "+0x" $8; \
+ print "#endif"; \
+} \
+'`
.section .data,"aw",@progbits
.globl ${SYMBOL}