bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/31009] regression: assertion fail ../../bfd/merge.c:243


From: nickc at redhat dot com
Subject: [Bug ld/31009] regression: assertion fail ../../bfd/merge.c:243
Date: Wed, 01 Nov 2023 11:12:01 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=31009

--- Comment #8 from Nick Clifton <nickc at redhat dot com> ---
Hi Jonny,

(In reply to Jonny Weir from comment #3)

> > Are you able to attach a debugger to the linker and discover the values that
> > are triggering this assertion ?  The code looks like this:
> 
> I attached gdb to the ld process, but I think a few things happen that make
> it more difficult to get a stack trace. I believe it forks another process
> and that is the process that spits out the assertion messages, so when that
> returns, there is no stack to examine. Unless there is a way to do this that
> I don't see, I cant see how to get the required stack trace.

As you have already found, using printf()s in a situation like this is
generally the best way to proceed, but just in case you are interested it is
possible to run gdb on the actual link process, although it is rather
complicated:

  1. Add "-Wl,-debug --save-temps" to the final g++ command line.  (NB, do not
add "-v")
  The output should look something like this:
  [...]
  o_file              = a.out.cdtor.o
  COLLECT_GCC_OPTIONS = '-flto' '-save-temps' '-mtune=generic' '-march=x86-64'
'-dumpdir' 'a.'
  COLLECT_GCC         = gcc
  COMPILER_PATH       =
/usr/libexec/gcc/x86_64-redhat-linux/13/:/usr/libexec/gcc/x86_64-redhat-linux/13/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/13/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH        =
/usr/lib/gcc/x86_64-redhat-linux/13/:/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/13/../../../:/lib/:/usr/lib/

  /bin/ld -plugin /usr/libexec/gcc/x86_64-redhat-linux/13/liblto_plugin.so
-plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
-plugin-opt=-fresolution=a.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --build-id
--no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2
/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-redhat-linux/13/crtbegin.o
-L/usr/lib/gcc/x86_64-redhat-linux/13
-L/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/13/../../.. a-hello.o
-lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state
--as-needed -lgcc_s --pop-state /usr/lib/gcc/x86_64-redhat-linux/13/crtend.o
/usr/lib/gcc/x86_64-redhat-linux/13/../../../../lib64/crtn.o
  /bin/ld: ./a.ltrans0.ltrans.o: in function `main':
  <artificial>:(.text+0x6): undefined reference to `fred'
  collect2: error: ld returned 1 exit status

(I am using a much smaller test program here, just to demonstrate how to
retrieve the final linker command line).

  2. Set the environment variables COLLECT_GCC and COLLECT_GCC_OPTIONS based
upon the output from the augmented command in step 1.

  3. Run "gdb /bin/ld" (or whichever linker path you are using).

  4. At gdb's command prompt set up any breakpoints you want and then "run" the
linker process, copying in the entire command line that is displayed in the
output from step 1.

If you run into a problem with the linker command line being too long, you can
save it into a file and then use "@<name-of-command-file>" instead.

I hope that this helps.

Cheers
  Nick

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]