summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-11-16 14:21:20 +1030
committerAlistair Popple <alistair@popple.id.au>2017-11-22 10:35:17 +1100
commit527fe54e1c95e031efd3db008c3f4e096cb3ea58 (patch)
tree8ecb73a760c8642a775143c2a7085d4720ea0505
parent58950eef124fcb37687f856fc5ee7936cb4e31cc (diff)
downloadpdbg-527fe54e1c95e031efd3db008c3f4e096cb3ea58.tar.gz
pdbg-527fe54e1c95e031efd3db008c3f4e096cb3ea58.zip
Rework generation of .dtb.o
The .dtb.o files are currently generated by compiling the .dts into .dtb, and then making a pass of objcopy to turn them into an ELF file that can be linked with the rest of pdbg. Unfortunately, this objcopy logic doesn't work on all platforms, because it doesn't generate an object file with the correct ABI flags. For example, on mips32r6, it fails to build with: mipsel-buildroot-linux-gnu/bin/ld: fake.dtb.o: warning: linking abicalls files with non-abicalls files mipsel-buildroot-linux-gnu/bin/ld: fake.dtb.o: linking -mnan=legacy module with previous -mnan=2008 modules mipsel-buildroot-linux-gnu/bin/ld: failed to merge target specific data of file fake.dtb.o mipsel-buildroot-linux-gnu/bin/ld: p8-fsi.dtb.o: warning: linking abicalls files with non-abicalls files In order to fix this, we want to generate a proper object file with gcc instead of playing tricks with objcopy, and this is what this commit implement. We have a template.S file, which gets sed'ed on the fly to point to the right file / use the right symbol name, and then is fed to gcc. This allows to remove all the objdump/objcopy logic from the configure.ac script as well. This fixes build issues of pdbg seems inside the Buildroot project: http://autobuild.buildroot.net/?reason=pdbg-77158819158d1d7053a737ac090d04fdfbfe9265 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Tested-by: Cyril Bur <cyrilbur@gmail.com> [joel: - integrate Cyril/Stephen's tr change - fix out of tree builds] Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--Makefile.am9
-rw-r--r--configure.ac11
-rw-r--r--template.S10
3 files changed, 12 insertions, 18 deletions
diff --git a/Makefile.am b/Makefile.am
index 5832590..9d34bff 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -61,10 +61,5 @@ p9r-fsi.dtb.o: p9r-fsi.dts p9-fsi.dtsi
p9z-fsi.dtb.o: p9z-fsi.dts p9-fsi.dtsi
%.dtb.o: %.dts
dtc -i$(dir $@) -I dts $< -O dtb > $@.tmp
-
-# We need to align the output as some processor/kernel
-# combinations can't deal with the alignment errors when
-# unflattening the device-tree
- dd if=$@.tmp of=$@ ibs=16 conv=sync
- rm $@.tmp
- $(OBJCOPY) -I binary -O @ARCH_FF@ $@ $@
+ symbol_prefix=`echo $@ | tr '.-' '_'` ; \
+ sed "s%SYMBOL_PREFIX%$${symbol_prefix}%g; s%FILENAME%$@.tmp%g" $(top_srcdir)/template.S | $(CC) -xassembler - -c -o $@
diff --git a/configure.ac b/configure.ac
index cf53f76..43348d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,15 +8,4 @@ AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_LANG(C)
-AC_SUBST([ARCH_FF])
-AC_CHECK_TOOL([OBJDUMP], [objdump])
-AC_CHECK_TOOL([OBJCOPY], [objcopy])
-AC_SUBST([OBJCOPY])
-AC_COMPILE_IFELSE(
- [AC_LANG_SOURCE([[]])],
- ARCH_FF=$(${OBJDUMP} -f conftest.$OBJEXT |
- sed -ne "s/.*file format //p" -e "s/.*architecture: \(.*\),.*/\1/p" |
- tr "\n" " " |
- sed -e "s/ / -B /"),
- AC_MSG_FAILURE([Unable to determine architecture output file format]))
AC_OUTPUT
diff --git a/template.S b/template.S
new file mode 100644
index 0000000..2e6cbdb
--- /dev/null
+++ b/template.S
@@ -0,0 +1,10 @@
+.section .data
+_binary_SYMBOL_PREFIX_start:
+.incbin "FILENAME"
+.align 4
+_binary_SYMBOL_PREFIX_end:
+_binary_SYMBOL_PREFIX_size:
+ .long _binary_SYMBOL_PREFIX_end - _binary_SYMBOL_PREFIX_start
+.globl _binary_SYMBOL_PREFIX_start
+.globl _binary_SYMBOL_PREFIX_end
+.globl _binary_SYMBOL_PREFIX_size
OpenPOWER on IntegriCloud