ld crashes while linking libcairo

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

ld crashes while linking libcairo

Post by Shine »

I've started to port the graphics lib cairo to PSP, but the linker crashs and I don't know how to fix it. This is the current version:

http://www.frank-buss.de/tmp/cairo.zip

To compile it:

Code: Select all

cd cairo
cd pixman/src/
make -f Makefile.psp
cd ../../src
make -f Makefile.psp
cd ../sample
make
Then I get this crash:

Code: Select all

...
collect2: ld terminated with signal 11 [Segmentation fault], core dumped
make: *** [cairotest.elf] Error 1

$ less ld.exe.stackdump
Exception: STATUS_ACCESS_VIOLATION at eip=0046E76B
eax=00000000 ebx=004C5F20 ecx=004BD062 edx=006A92D0 esi=006A5FA8 edi=006E6168
ebp=0022E828 esp=0022E7D0 program=C:\cygwin\usr\local\pspdev\psp\bin\ld.exe, pid 1240, thread main
cs=001B ds=0023 es=0023 fs=003B gs=0000 ss=0023
Stack trace:
Frame     Function  Args
0022E828  0046E76B  (004C5F20, 006E6168, 00000001, 00000000)
0022E888  0046E9D8  (004C5F20, 006AEF78, 00000000, 00000000)
0022E928  0046F2D0  (006DB478, 004C5F20, 006FD3E0, 006FBF68)
0022EB38  00433333  (006DB478, 004C5F20, 006CF0AA, 00000000)
0022ED48  00432B7D  (006BBE28, 004C5F20, 0022ED78, 00416BEA)
0022ED88  00409624  (0022EDA0, 00000000, 0022EDB8, 00421794)
0022EDB8  0040A02D  (00409BE0, 00000000, 00693328, 00693328)
0022EE68  0040F345  (00693368, 0049B4EC, 0049B4D2, 00411359)
0022EF18  004119C5  (00000021, 611556B0, 00690090, 7C929AF0)
0022EFD8  61004DD2  (0022EFF0, 77E500E8, 0022EFD8, 77E50000)
0022FF88  6100594F  (00000000, 00000000, 00000000, 00000000)
End of stack trace
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Do you get the same crash under Linux?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

It does for me. After following his instructions and having the build fail, you can reproduce it with just main.o and libcairo:

Code: Select all

neurosis:~/tmp/cairo/sample$ gdb `which psp-ld`
GNU gdb 6.3-debian
(gdb) set args -L../src main.o -lcairo
(gdb) r
Starting program: /usr/local/pspdev/bin/psp-ld -L../src main.o -lcairo

Program received signal SIGSEGV, Segmentation fault.
_bfd_mips_elf_hide_symbol (info=0x8103980, entry=0x815e650, force_local=1) at ../../bfd/elfxx-mips.c:8373
8373    ../../bfd/elfxx-mips.c: No such file or directory.
        in ../../bfd/elfxx-mips.c
(gdb) bt
#0  _bfd_mips_elf_hide_symbol (info=0x8103980, entry=0x815e650, force_local=1) at ../../bfd/elfxx-mips.c:8373
#1  0x0808b748 in mips_elf_record_global_got_symbol (h=0x815e650, abfd=0x812fd80, info=0x8103980, g=0x0, tls_flag=0 '\0')
    at ../../bfd/elfxx-mips.c:2635
#2  0x0808befe in _bfd_mips_elf_check_relocs (abfd=0x812fd80, info=0x8103980, sec=0x816e04c, relocs=0x8173a44)
    at ../../bfd/elfxx-mips.c:6151
#3  0x080a5153 in bfd_elf_link_add_symbols (abfd=0x812f798, info=0x8103980) at ../../bfd/elflink.c:4382
#4  0x080a35a4 in elf_link_add_archive_symbols (abfd=0x812f798, info=0x8103980) at ../../bfd/elflink.c:4650
#5  0x080a3bcb in bfd_elf_link_add_symbols (abfd=Variable "abfd" is not available.
) at ../../bfd/elflink.c:4706
#6  0x0805111e in load_symbols (entry=0x811976c, place=0xbfdc55c4) at ../../ld/ldlang.c:1869
#7  0x080575bf in open_input_bfds (s=0x811976c, force=0) at ../../ld/ldlang.c:2279
#8  0x08057788 in lang_process () at ../../ld/ldlang.c:4743
#9  0x08059bec in main (argc=4, argv=0xbfdc5794) at ../../ld/ldmain.c:458
(gdb)
Sorry, no time to look into it further at the moment.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

mrbrown wrote:Do you get the same crash under Linux?
Yes. As jimparis wrote, the crash is in binutils-psp/bfd/elfxx-mips.c:

Code: Select all

void
_bfd_mips_elf_hide_symbol (struct bfd_link_info *info,
                           struct elf_link_hash_entry *entry,
                           bfd_boolean force_local)
{
  bfd *dynobj;
  asection *got;
  struct mips_got_info *g;
  struct mips_elf_link_hash_entry *h;

  h = (struct mips_elf_link_hash_entry *) entry;
  if (h->forced_local)
    return;
  h->forced_local = force_local;

  dynobj = elf_hash_table (info)->dynobj;
  if (dynobj != NULL && force_local && h->root.type != STT_TLS)
    {
      got = mips_elf_got_section (dynobj, FALSE);
      g = mips_elf_section_data (got)->u.got_info;   --- crash line
...
"got" is 0. Maybe you know better how to debug it, because you added it to SVN :-)
chinaet
Posts: 7
Joined: Sun May 08, 2005 10:53 am

Post by chinaet »

[DELETED]
Last edited by chinaet on Tue Oct 11, 2005 1:06 am, edited 1 time in total.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

chinaet wrote:I am SUCCESS to build the sources in MAC OSX.no any crash.
So the example is working, too? I didn't know that I'm so good that there are no missing external references and the like :-) Which version of the PSPSDK toolchain did you use?

Please add a loop around the drawing function (perhaps 100 times) and measure how long it needs to execute it, to check if it is worth to invest some more time in it.
chinaet
Posts: 7
Joined: Sun May 08, 2005 10:53 am

Post by chinaet »

Sorry for my mistake.
I am JUST successful to compile the pixman and cairo library.
but got a error to compile the samples

Code: Select all

collect2: ld terminated with signal 10 [Bus error]
In linux box, the error messages is signal 11.

i try binutil 2.16.1 (with psp-patch) , but i got same error message.
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

I've added a check for NULL to the linker, now it says "undefined reference to `cairo_ft_scaled_font_backend'" instead of crashings and I can continue to port Cairo.
Post Reply