open-power / pdbg

PowerPC FSI Debugger
Apache License 2.0
17 stars 39 forks source link

Rework generation of .dtb.o #23

Closed tpetazzoni closed 6 years ago

tpetazzoni commented 6 years ago

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

Note: this has only been build tested, so please do some runtime testing before applying!

Note 2: there is possibly a better way than doing the horrible sed logic I came up with, suggestions welcome.

tpetazzoni commented 6 years ago

Thanks for the feedback. I see that Joel has taken over my changes (which is great!) and made those additional tweaks. So I guess I don't need to resend an updated version, and we can close this pull request ?

shenki commented 6 years ago

@tpetazzoni I'll leave this open until @apopple gets back in the country and has a moment to merge your changes.

Thanks again for the patches!

apopple commented 6 years ago

Thanks a lot for the patch Thomas and sorry for the delay merging it! I have merged a version with @shenki and @cyrilbur-ibm changes, hopefully it fixes the build errors you were seeing for some architectures in buildroot.