[prev in list] [next in list] [prev in thread] [next in thread]
List: pcc-list
Subject: Re: Mac OS X 10.6 Fixed compilation can, but not use debug option(-g).
From: "Shin'ichi Ichikawa" <chan () vivi-vine ! org>
Date: 2010-12-29 14:17:08
Message-ID: AANLkTikp=aKjDToO7i6enioj6vCkjNikeNASD2PpLK0R () mail ! gmail ! com
[Download RAW message or body]
Following the problem of debugging information.
$ pcc -g pcc_test.c
ld: warning: can't find atom for N_GSYM stabs ___stdinp:G15=*1 in
/tmp/ctm.6FCtvW
ld: warning: can't find atom for N_GSYM stabs ___stdoutp:G15 in /tmp/ctm.6FCtvW
ld: warning: can't find atom for N_GSYM stabs ___stderrp:G15 in /tmp/ctm.6FCtvW
ld: warning: can't find atom for N_GSYM stabs _sys_nerr:G1 in /tmp/ctm.6FCtvW
ld: warning: can't find atom for N_GSYM stabs
_sys_errlist:G16=ar1;0;-10202;17=*2 in /tmp/ctm.6FCtvW
$ pcc -g -S pcc_test.c
$ cat pcc_test.s
.LL82:
.stabs "___stdinp:G15=*1",32,0,8,0
.stabs "___stdoutp:G15",32,0,8,0
.stabs "___stderrp:G15",32,0,8,0
.stabs "/usr/include//stdio.h",132,0,0,.LL83
.LL83:
.stabs "/usr/include//stdio.h",132,0,0,.LL84
.LL84:
.stabs "/usr/include//stdio.h",132,0,0,.LL85
.LL85:
.stabs "_sys_nerr:G1",32,0,4,0
.stabs "_sys_errlist:G16=ar1;0;-10202;17=*2",32,0,0,0
.stabs "/usr/include//stdio.h",132,0,0,.LL86
2010/12/29 Shin'ichi Ichikawa <chan@vivi-vine.org>:
> Hi, fixed typo and side effects of exname().
>
> diff -rup pcc-101229/arch/amd64/code.c pcc/arch/amd64/code.c
> --- pcc-101229/arch/amd64/code.c 2010-12-27 02:26:03.000000000 +0900
> +++ pcc/arch/amd64/code.c 2010-12-29 19:48:45.000000000 +0900
> @@ -397,8 +397,8 @@ ejobcode(int flag )
> if (flag)
> return;
>
> -#ifdef MACHOAPI
> -#define PT(x)
> +#ifdef MACHOABI
> +#define PT(x) printf("_")
> #else
> #define PT(x) printf(".type __pcc_" x ",@function\n")
> #endif
>
> 2010/12/11 Anders Magnusson <ragge@ludd.ltu.se>:
>> Hi,
>>
>> On 12/11/2010 01:51 PM, Shin'ichi Ichikawa wrote:
>>>
>>> Hi, able to compile the attached patch !
>>>
>> Done, thanks! ...with a few changes;
>> - use exname() to create symbols with a prepended _ instead of hand-crafting
>> it.
>> - I assume .byte should be .space for zeroed area.
>>
>> You may want to doublecheck my changes.
>>
>> Thank you very much for your patches!
>>
>> -- Ragge
>>
>>
>>> $ pwd
>>> /usr/local/lib/pcc/i386-apple-darwin10.5.0/0.9.9/lib
>>>
>>> $ ls -lF
>>> total 112
>>> -rw-r--r-- 1 root wheel 20048 12 11 08:52 libpcc.a
>>> -rw-r--r-- 1 root wheel 36320 12 11 08:52 libpccsoftfloat.a
>>>
>>> $ sudo cp -p /usr/lib/crt1.* .
>>> Password:
>>>
>>> $ ls -lF
>>> total 208
>>> -rw-r--r-- 1 root wheel 13260 9 30 2009 crt1.10.5.o
>>> -rw-r--r-- 1 root wheel 12984 9 30 2009 crt1.10.6.o
>>> -rw-r--r-- 1 root wheel 15768 9 30 2009 crt1.o
>>> -rw-r--r-- 1 root wheel 20048 12 11 08:52 libpcc.a
>>> -rw-r--r-- 1 root wheel 36320 12 11 08:52 libpccsoftfloat.a
>>>
>>> $ pcc pcc_test.c
>>> $ cat pcc_test.c
>>>
>>> #include<stdarg.h>
>>> #include<stdio.h>
>>>
>>> static int x(const int i, ...)
>>> {
>>> static int x = 0;
>>> x += i;
>>>
>>> va_list ap;
>>> va_start(ap, i);
>>> x += va_arg(ap, int);
>>> va_end(ap);
>>>
>>> return x;
>>> }
>>>
>>> int main()
>>> {
>>> int y = x(1, 1);
>>> ++y;
>>> printf("y = %d¥n", y);
>>>
>>> return 0;
>>> }
>>> $ ./a.out
>>> y = 3
>>>
>>>
>>> diff -rup pcc-101210/arch/amd64/code.c pcc/arch/amd64/code.c
>>> --- pcc-101210/arch/amd64/code.c 2010-11-28 18:32:21.000000000
>>> +0900
>>> +++ pcc/arch/amd64/code.c 2010-12-11 18:36:51.000000000 +0900
>>> @@ -86,8 +86,13 @@ defloc(struct symtab *sp)
>>> return;
>>> }
>>> if (kflag) {
>>> +#ifndef MACHOABI
>>> loctbl[DATA] = "section .data.rel.rw,¥"aw¥",@progbits";
>>> loctbl[RDATA] = "section .data.rel.ro,¥"aw¥",@progbits";
>>> +#else
>>> + loctbl[DATA] = "section .data.rel.rw,¥"aw¥"";
>>> + loctbl[RDATA] = "section .data.rel.ro,¥"aw¥"";
>>> +#endif
>>> }
>>> t = sp->stype;
>>> s = ISFTN(t) ? PROG : ISCON(cqual(t, sp->squal)) ? RDATA : DATA;
>>> @@ -144,12 +149,24 @@ defloc(struct symtab *sp)
>>> if (weak)
>>> printf(" .weak %s¥n", name);
>>> else if (sp->sclass == EXTDEF) {
>>> +#ifndef MACHOABI
>>> printf("¥t.globl %s¥n", name);
>>> printf("¥t.type %s,@%s¥n", name,
>>> ISFTN(t)? "function" : "object");
>>> +#else
>>> + printf("¥t.globl _%s¥n", name);
>>> +#endif
>>> }
>>> if (sp->slevel == 0)
>>> +#ifndef MACHOABI
>>> printf("%s:¥n", name);
>>> +#else
>>> + if (sp->sclass == EXTDEF) {
>>> + printf("_%s:¥n", name);
>>> + }else{
>>> + printf("%s:¥n", name);
>>> + }
>>> +#endif
>>> else
>>> printf(LABFMT ":¥n", sp->soffset);
>>> }
>>> @@ -376,7 +393,11 @@ ejobcode(int flag )
>>>
>>> /* printout varargs routines if used */
>>> if (varneeds& NEED_GPNEXT) {
>>> +#ifndef MACHOABI
>>> printf(".text¥n.align 4¥n.type __pcc_gpnext,@function¥n");
>>> +#else
>>> + printf(".text¥n.align 4¥n");
>>> +#endif
>>> printf("__pcc_gpnext:¥n");
>>> printf("cmpl $48,(%%rdi)¥njae 1f¥n");
>>> printf("movl (%%rdi),%%eax¥naddq 16(%%rdi),%%rax¥n");
>>> @@ -385,7 +406,11 @@ ejobcode(int flag )
>>> printf("addq $8,8(%%rdi)¥nret¥n");
>>> }
>>> if (varneeds& NEED_FPNEXT) {
>>> +#ifndef MACHOABI
>>> printf(".text¥n.align 4¥n.type __pcc_fpnext,@function¥n");
>>> +#else
>>> + printf(".text¥n.align 4¥n");
>>> +#endif
>>> printf("__pcc_fpnext:¥n");
>>> printf("cmpl $176,4(%%rdi)¥njae 1f¥n");
>>> printf("movl 4(%%rdi),%%eax¥naddq 16(%%rdi),%%rax¥n");
>>> @@ -394,7 +419,11 @@ ejobcode(int flag )
>>> printf("addq $8,8(%%rdi)¥nret¥n");
>>> }
>>> if (varneeds& NEED_1REGREF) {
>>> +#ifndef MACHOABI
>>> printf(".text¥n.align 4¥n.type __pcc_1regref,@function¥n");
>>> +#else
>>> + printf(".text¥n.align 4¥n");
>>> +#endif
>>> printf("__pcc_1regref:¥n");
>>> printf("cmpl $48,(%%rdi)¥njae 1f¥n");
>>> printf("movl (%%rdi),%%eax¥naddq 16(%%rdi),%%rax¥n");
>>> @@ -403,7 +432,11 @@ ejobcode(int flag )
>>> printf("addq $8,8(%%rdi)¥nret¥n");
>>> }
>>> if (varneeds& NEED_2REGREF) {
>>> +#ifndef MACHOABI
>>> printf(".text¥n.align 4¥n.type __pcc_2regref,@function¥n");
>>> +#else
>>> + printf(".text¥n.align 4¥n");
>>> +#endif
>>> printf("__pcc_2regref:¥n");
>>> printf("cmpl $40,(%%rdi)¥njae 1f¥n");
>>> printf("movl (%%rdi),%%eax¥naddq 16(%%rdi),%%rax¥n");
>>> @@ -412,7 +445,11 @@ ejobcode(int flag )
>>> printf("addq $16,8(%%rdi)¥nret¥n");
>>> }
>>> if (varneeds& NEED_MEMREF) {
>>> +#ifndef MACHOABI
>>> printf(".text¥n.align 4¥n.type __pcc_memref,@function¥n");
>>> +#else
>>> + printf(".text¥n.align 4¥n");
>>> +#endif
>>> printf("__pcc_memref:¥n");
>>> printf("movq 8(%%rdi),%%rax¥n");
>>> printf("addq %%rsi,8(%%rdi)¥nret¥n");
>>> @@ -422,7 +459,11 @@ ejobcode(int flag )
>>> #define _MKSTR(x) #x
>>> #define MKSTR(x) _MKSTR(x)
>>> #define OS MKSTR(TARGOS)
>>> +#ifndef MACHOABI
>>> printf("¥t.ident ¥"PCC: %s (%s)¥"¥n¥t.end¥n", PACKAGE_STRING,
>>> OS);
>>> +#else
>>> + printf("¥t.ident ¥"PCC: %s (%s)¥"¥n", PACKAGE_STRING, OS);
>>> +#endif
>>> }
>>>
>>> /*
>>> diff -rup pcc-101210/arch/amd64/local.c pcc/arch/amd64/local.c
>>> --- pcc-101210/arch/amd64/local.c 2010-12-03 17:05:13.000000000
>>> +0900
>>> +++ pcc/arch/amd64/local.c 2010-12-11 18:36:07.000000000 +0900
>>> @@ -101,7 +101,11 @@ picext(NODE *p)
>>> g = ISFTN(p->n_sp->stype) ? "@PLT" : "@GOTPCREL";
>>> #endif
>>> g = "@GOTPCREL";
>>> +#ifndef MACHOABI
>>> sp = picsymtab("", c, g);
>>> +#else
>>> + sp = picsymtab("_", c, g);
>>> +#endif
>>> sp->sflags = SBEENHERE;
>>> q = block(NAME, NIL, NIL, INCREF(p->n_type), p->n_df, p->n_ap);
>>> q->n_sp = sp;
>>> @@ -837,7 +841,11 @@ zbits(OFFSZ off, int fsz)
>>> }
>>> }
>>> if (fsz>= SZCHAR) {
>>> +#ifndef MACHOABI
>>> printf("¥t.zero %d¥n", fsz/SZCHAR);
>>> +#else
>>> + printf("¥t.byte %d¥n", fsz/SZCHAR);
>>> +#endif
>>> fsz -= (fsz/SZCHAR) * SZCHAR;
>>> }
>>> if (fsz) {
>>> diff -rup pcc-101210/arch/amd64/local2.c pcc/arch/amd64/local2.c
>>> --- pcc-101210/arch/amd64/local2.c 2010-12-05 05:52:16.000000000
>>> +0900
>>> +++ pcc/arch/amd64/local2.c 2010-12-11 08:18:17.000000000 +0900
>>> @@ -129,7 +129,9 @@ eoftn(struct interpass_prolog *ipp)
>>> printf(" leave¥n");
>>> printf(" ret¥n");
>>> }
>>> +#ifndef MACHOABI
>>> printf("¥t.size %s,.-%s¥n", ipp->ipp_name, ipp->ipp_name);
>>> +#endif
>>> }
>>>
>>> /*
>>>
>>>
>>> 2010/6/25 Shin'ichi Ichikawa<chan@vivi-vine.org>:
>>>>
>>>> Hi,
>>>>
>>>> In fact compared to gcc turns out quite different from the output of
>>>> the assembler source code.
>>>> PCC may be better prepared with a compatible assembler. In the next
>>>> Xcode, there are rumors that the compiler will LLVM, Apple would be
>>>> better idea of independent tools.
>>>>
>>>> $ gcc -v
>>>> Using built-in specs.
>>>> Target: i686-apple-darwin10
>>>> Configured with: /var/tmp/gcc/gcc-5659~1/src/configure
>>>> --disable-checking --enable-werror --prefix=/usr --mandir=/share/man
>>>> --enable-languages=c,objc,c++,obj-c++
>>>> --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/
>>>> --with-slibdir=/usr/lib --build=i686-apple-darwin10
>>>> --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10
>>>> --target=i686-apple-darwin10 --with-gxx-include-dir=/include/c++/4.2.1
>>>> Thread model: posix
>>>> gcc version 4.2.1 (Apple Inc. build 5659)
>>>>
>>>> $ cat test2.c
>>>> int main()
>>>> {
>>>> return 0;
>>>> }
>>>>
>>>> $ gcc -S test2.c
>>>>
>>>> $ cat test2.s
>>>> .text
>>>> .globl _main
>>>> _main:
>>>> LFB2:
>>>> pushq %rbp
>>>> LCFI0:
>>>> movq %rsp, %rbp
>>>> LCFI1:
>>>> movl $0, %eax
>>>> leave
>>>> ret
>>>> LFE2:
>>>> .section
>>>> __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support
>>>> EH_frame1:
>>>> .set L$set$0,LECIE1-LSCIE1
>>>> .long L$set$0
>>>> LSCIE1:
>>>> .long 0x0
>>>> .byte 0x1
>>>> .ascii "zR\0"
>>>> .byte 0x1
>>>> .byte 0x78
>>>> .byte 0x10
>>>> .byte 0x1
>>>> .byte 0x10
>>>> .byte 0xc
>>>> .byte 0x7
>>>> .byte 0x8
>>>> .byte 0x90
>>>> .byte 0x1
>>>> .align 3
>>>> LECIE1:
>>>> .globl _main.eh
>>>> _main.eh:
>>>> LSFDE1:
>>>> .set L$set$1,LEFDE1-LASFDE1
>>>> .long L$set$1
>>>> LASFDE1:
>>>> .long LASFDE1-EH_frame1
>>>> .quad LFB2-.
>>>> .set L$set$2,LFE2-LFB2
>>>> .quad L$set$2
>>>> .byte 0x0
>>>> .byte 0x4
>>>> .set L$set$3,LCFI0-LFB2
>>>> .long L$set$3
>>>> .byte 0xe
>>>> .byte 0x10
>>>> .byte 0x86
>>>> .byte 0x2
>>>> .byte 0x4
>>>> .set L$set$4,LCFI1-LCFI0
>>>> .long L$set$4
>>>> .byte 0xd
>>>> .byte 0x6
>>>> .align 3
>>>> LEFDE1:
>>>> .subsections_via_symbols
>>>>
>>>> 2010/6/24 Shin'ichi Ichikawa<chan@vivi-vine.org>:
>>>>>
>>>>> 2010/6/23 Anders Magnusson<ragge@ludd.ltu.se>:
>>>>>>
>>>>>> Not so strange since you are probably the first person trying to
>>>>>> compile on
>>>>>> 64-bit darwin :-)
>>>>>>
>>>>>> Anyway, we should find out what the ops should be on macosx to fix
>>>>>> this. I
>>>>>> do not have
>>>>>> any such machine closeby.
>>>>>
>>>>> Because of the directives are not compatible,
>>>>> GNU assembler seems to have failed to perform.
>>>>>
>>>>> $ cat test2.c
>>>>> int main()
>>>>> {
>>>>> return 0;
>>>>> }
>>>>>
>>>>> $ pcc -S test2.c
>>>>>
>>>>> $ cat test2.s
>>>>> .text
>>>>> .align 4
>>>>> .globl main
>>>>> .type main,@function
>>>>> main:
>>>>> pushq %rbp
>>>>> movq %rsp,%rbp
>>>>> subq $16,%rsp
>>>>> .L11:
>>>>> .L13:
>>>>> movl $0,-4(%rbp)
>>>>> jmp .L12
>>>>> .L12:
>>>>> movl -4(%rbp),%eax
>>>>> leave
>>>>> ret
>>>>> .size main,.-main
>>>>> .ident "PCC: pcc 0.9.9 (darwin)"
>>>>> .end
>>>>>
>>>>> $ as -v
>>>>> Apple Inc version cctools-773~33, GNU assembler version 1.38
>>>>>
>>>>> $ as test2.s
>>>>> test2.s:4:Unknown pseudo-op: .type
>>>>> test2.s:4:Rest of line ignored. 1st junk character valued 109 (m).
>>>>> test2.s:17:Unknown pseudo-op: .size
>>>>> test2.s:17:Rest of line ignored. 1st junk character valued 109 (m).
>>>>> test2.s:19:Unknown pseudo-op: .end
>>
>>
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic