<< Back to previous view

[PCC-10] stabs on OS X i386 cause Bus error in ld Created: 03/Dec/08  Updated: 08/Dec/08

Status: Closed
Project: pcc
Component/s: C frontend
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Gregory McGarry Assignee: Gregory McGarry
Resolution: Fixed Votes: 0
Environment: OS X 10.5 intel (gcc 4.0.1, ld ld64-77)


 Description   
Compiling a helloworld.c with -g to generate stabs causes Bus error in ld.

$ pcc -v -g hw.c
pcc 0.9.9 for i386-apple-darwin9.5.0, gmcgarry@macbook.local Wed Dec 3 18:03:52 EST 2008
/usr/local/libexec/cpp -v -D__PCC__=0 -D__PCC_MINOR__=9 -D__PCC_MINORMINOR__=9 -D__Darwin__ -I/usr/local/include//pcc -D__i386__ -D__LITTLE_ENDIAN__ -S /usr/include/ -I /usr/local/lib/pcc/i386-apple-darwin9.5.0/0.9.9/include/ hw.c /tmp/ctm.NiBE3T
cpp: pcc 0.9.9 for i386-apple-darwin9.5.0, gmcgarry@macbook.local Wed Dec 3 18:03:52 EST 2008
/usr/local/libexec/ccom -v -g -k /tmp/ctm.NiBE3T /tmp/ctm.oBk9wD
ccom: pcc 0.9.9 for i386-apple-darwin9.5.0, gmcgarry@macbook.local Wed Dec 3 18:03:52 EST 2008
as -v -o hw.o /tmp/ctm.oBk9wD
Apple Computer, Inc. version cctools-667.3~21, GNU assembler version 1.38
ld -v -e start /usr/lib/crt1.o hw.o -L/usr/local/lib/pcc/i386-apple-darwin9.5.0/0.9.9/lib/ -lSystem -lpcc
@(#)PROGRAM:ld PROJECT:ld64-77
Library search paths:
/usr/local/lib/pcc/i386-apple-darwin9.5.0/0.9.9/lib/
/usr/lib
/usr/local/lib
Framework search paths:
/Library/Frameworks/
/System/Library/Frameworks/
/Network/Library/Frameworks/
can't find atom for N_GSYM stabs __stdinp:G15=*1 in hw.o
can't find atom for N_GSYM stabs __stdoutp:G15 in hw.o
can't find atom for N_GSYM stabs __stderrp:G15 in hw.o
can't find atom for N_GSYM stabs sys_nerr:G1 in hw.o
can't find atom for N_GSYM stabs sys_errlist:G16=ar1;0;-10202;17=*2 in hw.o
Bus error

This error is also visible when running ./configure in pcc with PCC=pcc. Many of the tests fail because configure uses -g to compile all the conftest.c programs.

I couldn't reproduce this problem on Ubuntu, so maybe it's another problem with GNU deviating from the stabs specification again.

 Comments   
Comment by Gregory McGarry [ 04/Dec/08 11:23 PM ]
The problem is caused by pcc not inserting "end of text segment" stab entries.

ld on OS X 10.5 seems to need them. At least the intel version does.

The following stab needs to be inserted at the end of the text segment:

        .stabs "",100,0,0,Letext0
Letext0:


Additionally, gcc has a nice feature of trapping signals from ld:

collect2: ld terminated with signal 10 [Bus error]

It would be nice to have this feature in pcc - it makes it easier to isolate problems quickly.

Comment by Gregory McGarry [ 04/Dec/08 11:26 PM ]
Problem found in the C front-end.

Comment by Gregory McGarry [ 08/Dec/08 10:41 PM ]
Fixed.
Generated at Sat Nov 01 02:11:12 CET 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.