<< Back to previous view

[PCC-268] function (symbol?) renaming does not work with pre-declared functions Created: 01/Mar/11  Updated: 01/May/14

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

Type: Bug Priority: Major
Reporter: Iain Hibbert Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
Environment: NetBSD/i386


 Description   
The following code

void bar(void);

static inline void foo(void)
{
bar();
}

void bar(void) asm("__bar");

void baz(void)
{
foo();
bar();
}

when compiled with "pcc -S":

.text
.align 4
.globl baz
.type baz,@function
baz:
pushl %ebp
movl %esp,%ebp
.L16:
.L18:
call foo
call __bar
.L17:
leave
ret
.size baz,.-baz
.align 4
foo:
pushl %ebp
movl %esp,%ebp
.L19:
.L21:
call bar
.L20:
leave
ret
.size foo,.-foo
.ident "PCC: pcc 1.1.0.DEVEL [20110221] (netbsd)"

shows a call to bar() from the foo() function even though its written out after the declaration that renames the symbol

..arguably this code is slightly controversial though it does work with gcc..

 Comments   
Comment by Iain Hibbert [ 15/May/11 07:00 PM ]
Actually, this might be simpler than that, it seems that function renaming
does not work at all with statically declared functions. The following code

void foo (void) __asm("__foo");

void foo (void)
{
    foo();
}

static void bar (void) __asm("__bar");

static void bar (void)
{
    bar();
}

illustrates the problem, when compiled with "pcc -S" produces

        .text
        .align 4
        .globl __foo
        .type __foo,@function
__foo:
        pushl %ebp
        movl %esp,%ebp
.L11:
.L13:
        call __foo
.L12:
        leave
        ret
        .size __foo,.-__foo
        .align 4
bar:
        pushl %ebp
        movl %esp,%ebp
.L14:
.L16:
        call bar
.L15:
        leave
        ret
        .size bar,.-bar
        .ident "PCC: pcc 1.1.0.DEVEL [20110513] (netbsd)"

as you can see, the "bar" function has not been renamed..
Comment by Anders Magnusson [ 01/May/14 02:31 PM ]
Fixed now. It worked when rename was not added to the prototype.
Generated at Thu Oct 02 08:27:59 CEST 2014 using JIRA Enterprise Edition, Version: 3.13.1-#333.