bug-gnu-utils
[Top][All Lists]
Advanced

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

BFD problems?


From: Jindrich Kubec
Subject: BFD problems?
Date: Mon, 04 Mar 2002 21:39:22 +0100

Hi,

I've encountered strange problem when ld creates BFD unreadable object. M$ dumpbin, also my utils have no problems reading it.

I'm using Win2000, cygwin environment. GNU ld version 2.11.92 20011001. No patches applied, using cygwin binaries.

Output of objdump -x is:
BFD: BFD internal error, aborting at /cygnus/netrel/src/binutils-20011002-1/bfd/coffcode.h line 810
in handle_COMDAT

I don't care for objdump, but any BFD aware app, including ld has problem reading the file -> I can't link it anymore.

Problem lies in link.ld, when I omit -T link.ld option, the result is okay (from BFD's pov, not for me). The whole problem is inclusion of *(.text$*) and *(.data$*).

I run ld with these options:
>ld -Ur -O99 -T link.ld -L . input_objects -o output_object

link.ld:

OUTPUT_FORMAT(pe-i386)
ENTRY(start)
SECTIONS
{
  .text 0x0: {
    *(.text)
    etext  =  . ; _etext = .;
    djgpp_first_ctor = . ;
    *(.ctor)
    djgpp_last_ctor = . ;
    djgpp_first_dtor = . ;
    *(.dtor)
    djgpp_last_dtor = . ;
    *(.data)
     edata  =  . ; _edata = .;
    *(.bss)
     ebss  =  . ; _ebss = .;
  }

  .none :{
    *(.text$*)
    *(.data$*)
  }
}

Then I strip out everything but .text segment by my own util.

Reason I'm doing such strange things is, that I want to use my own dynamic loader and I don't want to be os dependent. I'm unable to tell the compiler that I don't want the code in .text$* sections, that's the whole problem for me now.

I meanwhile I found nice thing in docs -> instead of .none I used /DISCARD/ which now created BFD readable object. When I link the object to my app, it does work now. Because it has some problems, I wanted to debug it. It works, but without source code & symbols. So I compiled it with -g switch and linked together. Result:

>gcc -g --verbose --print-map -t Client.o avapi.o vps/vps.obj -lc -o client

Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs

gcc version 2.95.3-5 (cygwin special)

/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/collect2.exe -Bdynamic --dll-search-prefix=cyg -o client.exe -t /usr/lib/crt0.o -L/usr/local/lib -L/usr/lib -L/usr/lib/w32api -L/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5 Client.o avapi.o vps/vps.obj -lc -lgcc -lcygwin -luser32 -lkernel32 -ladvapi32 -lshell32 -lgcc
collect2: ld terminated with signal 11 [Segmentation fault]

/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/../../../../i686-pc-cygwin/bin/ld: warning: cannot find entry symbol _mainCRTStartup; defaulting to 00401000

/usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/../../../../i686-pc-cygwin/bin/ld: bfd assertion fail /cygnus/netrel/src/binutils-20011002-1/bfd/cofflink.c:1950

I'm sorry that I didn't understand the code mentioned in the error messages ;)

I could send you objdump report of the object causing the problems, just tell me which switches are useful.

BTW: The option '-i' is in documentation mentioned to be same as '-r'. But it isn't - it needs some number parameter.


Jindroush (address@hidden)
http://jindroush.atari.org - Home of Atari Cartridge Dumping Project.




reply via email to

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