Test case which displays problem found in libstdc++-v3 effort

Alan Modra alan@linuxcare.com.au
Thu Jun 22 18:12:00 GMT 2000

On 22 Jun 2000, Jason Merrill wrote:

> >>>>> Alan Modra <alan@linuxcare.com.au> writes:
>  > On 19 Jun 2000, Jason Merrill wrote:
>  >> >>>>> Alan Modra <alan@linuxcare.com.au> writes:
>  >> 
>  >>  > It's a linker script bug.  The linker needs to be told to keep the
>  >>  > .eh_frame contents.  Lack of any reference to symbols defined in a
>  >>  > section normally causes --gc-sections to discard the section.
>  >> 
>  >> I would think that the reference to __EH_FRAME_BEGIN__ from
>  >> __do_global_ctors would satisfy the linker.  Why doesn't it?
>  > Because there doesn't seem to be any such reference.  __main.o doesn't
>  > have much in it on i586-linux.
> What about crt{begin,end}.o?

Yep, there's a reference to __EH_FRAME_BEGIN__ in crtbegin.o.  Sooo, this
makes it a linker bug after all, and my patch to the script is just
papering over the problem.  Hmm, looking at objdump output, we actually
get a reference to the section symbol:

  35:   68 00 00 00 00          push   $0x0
                        36: R_386_32    .eh_frame
  3a:   e8 fc ff ff ff          call   3b <__do_global_dtors_aux+0x3b>

That ought to be enough to ensure the .eh_frame section gets kept, but I'm
guessing that section symbols aren't looked at for some reason.  I'll see
if I can fix this later on today if I find some time.

Here's a very simple set of test files if someone else wants to look at
this problem

cat > t1.s <<EOF
 .global _start
 mov __EH_FRAME_BEGIN__, %eax
 jmp _start

 .section .keepme,"aw"
 .type __EH_FRAME_BEGIN__,@object
cat > t2.s <<EOF
 .section .keepme,"aw"
 .long 0
as -o t1.o t1.s
as -o t2.o t2.s
ld -static --gc-sections t1.o t2.o
objdump --headers a.out

a.out:     file format elf32-i386

Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000000a  08048074  08048074  00000074  2**2
  1 .sbss         00000000  0804907e  0804907e  0000007e  2**0
  2 .bss          00000002  0804907e  0804907e  0000007e  2**0
  3 .keepme       00000000  0804907e  0804907e  0000007e  2**0
                  CONTENTS, ALLOC, LOAD, DATA

And .keepme should be 4 bytes long.

Regards, Alan Modra
Linuxcare.  Support for the Revolution.

More information about the Binutils mailing list