debugging collect2...

Alan Lehotsky alehotsky@codegentllc.com
Fri Sep 4 19:06:36 GMT 2020
I’m trying to debug a segv in ld when running the ld-pie tests.

I did a 

     gcc -v -pie -o pie    $src/binutils/ld/testsuite/ld-pie/pie.c

and get the collect line.

There appear to be a bunch of env vars that get reported in the sequence…

I then startup gdb on collect2
Do a number of

	set env …

to setup the envars

Then in order to get the ld that’s crashing,

	set follow-fork child

and then run collect2 with the args.

run -plugin /local/mnt/nx/alehotsk/fixup/toolchain/install/bin/../libexec/gcc/XXX-none-elf/8.1.1/liblto_plugin.so -plugin-opt=/local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../libexec/gcc/XXX-none-elf/8.1.1/lto-wrapper -plugin-opt=-fresolution=pie.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc -V -Qy -EL -pie -o pie /local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/../../../../XXX-none-elf/lib/crt0.o /local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/crti.o /local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/crtbegin.o -L/local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1 -L/local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc -L/local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/../../../../XXX-none-elf/lib pie.o -lgcc --start-group -lc -lgcc --end-group -lgcc /local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/crtend.o /local/mnt/nx/alehotsk/fixup/XXX-toolchain/install/bin/../lib/gcc/XXX-none-elf/8.1.1/crtn.o
collect2: fatal error: cannot find ‘ld'
compilation terminated.


How do I debug this short of getting the core dump from the original segv



Alan Lehotsky
https://codegentllc.com





More information about the Binutils mailing list