This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: trees: function declaration


No help? :-)

BTW Is there any documenation on machine?
I am looking at this one:
http://www.mhatt.aps.anl.gov/dohn/programming/gcc/gccint.html#SEC_Top

it might have been something else?

Thank you.

----- Forwarded message from george@georgeshagov.com -----
    Date: Wed, 08 Feb 2006 08:02:20 -0600
    From: george@georgeshagov.com
Reply-To: george@georgeshagov.com
 Subject: trees: function declaration
      To: GCC Development <gcc@gcc.gnu.org>

Gentlemen.

I need some kind of assistance. I am trying to substitute function name during
the compilation procedure.
In order to do that I am:
1. creating new identifier with my name, like this:
t = get_identifier("Myfuction__ml_stub");
2. setting this name:
DECL_NAME(funcition) = t;
function is the parameter of build_function_call (tree function, tree params)
3. changing assembler name:
SET_DECL_ASSEMBLER_NAME(funcition, t);

What I have:
My sample app:

#include <stdio.h>

extern int Myfunction();

/*
int Myfunction()
{
	printf("asd");
}
*/

int main()
{
  Myfunction();
  return 0;
}

in case  the body of Myfunction is commented out, everything looks fine:
the dump:
@1      function_decl    name: @2       mngl: @3       type: @4
                         srcp: test.c:3                undefined
                         extern
@2      string_cst       strg: myfunction__ml_stub lngt: 20
@3      identifier_node  strg: myfunction__ml_stub     lngt: 19
@4      function_type    size: @5       algn: 8        retn: @6
@5      integer_cst      type: @7       low : 8
@6      integer_type     name: @8       size: @9       algn: 32
                         prec: 32       min : @10      max : @11
@7      integer_type     name: @12      unql: @13      size: @14
                         algn: 64       prec: 36       unsigned
                         min : @15      max : @16
@8      type_decl        name: @17      type: @6       srcp: <built-in>:0
@9      integer_cst      type: @7       low : 32
@10     integer_cst      type: @6       high: -1       low : -2147483648
@11     integer_cst      type: @6       low : 2147483647
@12     identifier_node  strg: bit_size_type           lngt: 13
@13     integer_type     name: @12      size: @14      algn: 64
                         prec: 36
@14     integer_cst      type: @7       low : 64
@15     integer_cst      type: @7       low : 0
@16     integer_cst      type: @7       high: 15       low : -1
@17     identifier_node  strg: int      lngt: 3


asm:
	.file	"test.c"
	.text
.globl main
	.type	main, @function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	andl	$-16, %esp
	movl	$0, %eax
	addl	$15, %eax
	addl	$15, %eax
	shrl	$4, %eax
	sall	$4, %eax
	subl	%eax, %esp
	call	Myfunction__ml_stub
	movl	$0, %eax
	leave
	ret
	.size	main, .-main
	.ident	"GCC: (GNU) 4.0.2"
	.section	.note.GNU-stack,"",@progbits

so it works.

yet when the function body is not commented:

#include <stdio.h>

extern int Myfunction();

int Myfunction()
{
	printf("asd");
}

int main()
{
  Myfunction();
  return 0;
}

I have:

@1      function_decl    name: @2       type: @3       srcp: stdio.h:0
                         undefined      extern
@2      identifier_node  strg: printf__ml_stub         lngt: 15
@3      function_type    size: @4       algn: 8        retn: @5
                         prms: @6
@4      integer_cst      type: @7       low : 8
@5      integer_type     name: @8       size: @9       algn: 32
                         prec: 32       min : @10      max : @11
@6      tree_list        valu: @12
@7      integer_type     name: @13      unql: @14      size: @15
                         algn: 64       prec: 36       unsigned
                         min : @16      max : @17
@8      type_decl        name: @18      type: @5       srcp: <built-in>:0
@9      integer_cst      type: @7       low : 32
@10     integer_cst      type: @5       high: -1       low : -2147483648
@11     integer_cst      type: @5       low : 2147483647
@12     pointer_type     qual:   r      unql: @19      size: @9
                         algn: 32       ptd : @20
@13     identifier_node  strg: bit_size_type           lngt: 13
@14     integer_type     name: @13      size: @15      algn: 64
                         prec: 36
@15     integer_cst      type: @7       low : 64
@16     integer_cst      type: @7       low : 0
@17     integer_cst      type: @7       high: 15       low : -1
@18     identifier_node  strg: int      lngt: 3
@19     pointer_type     size: @9       algn: 32       ptd : @20
@20     integer_type     qual: c        name: @21      unql: @22
                         size: @4       algn: 8        prec: 8
                         min : @23      max : @24
@21     type_decl        name: @25      type: @22      srcp: <built-in>:0
@22     integer_type     name: @21      size: @4       algn: 8
                         prec: 8        min : @23      max : @24
@23     integer_cst      type: @22      high: -1       low : -128
@24     integer_cst      type: @22      low : 127
@25     identifier_node  strg: char     lngt: 4









@1      function_decl    name: @2       type: @3       srcp: test.c:0
                         undefined      extern
@2      identifier_node  strg: Myfunction__ml_stub     lngt: 19
@3      function_type    unql: @4       size: @5       algn: 8
                         retn: @6
@4      function_type    size: @5       algn: 8        retn: @6
@5      integer_cst      type: @7       low : 8
@6      integer_type     name: @8       size: @9       algn: 32
                         prec: 32       min : @10      max : @11
@7      integer_type     name: @12      unql: @13      size: @14
                         algn: 64       prec: 36       unsigned
                         min : @15      max : @16
@8      type_decl        name: @17      type: @6       srcp: <built-in>:0
@9      integer_cst      type: @7       low : 32
@10     integer_cst      type: @6       high: -1       low : -2147483648
@11     integer_cst      type: @6       low : 2147483647
@12     identifier_node  strg: bit_size_type           lngt: 13
@13     integer_type     name: @12      size: @14      algn: 64
                         prec: 36
@14     integer_cst      type: @7       low : 64
@15     integer_cst      type: @7       low : 0
@16     integer_cst      type: @7       high: 15       low : -1
@17     identifier_node  strg: int      lngt: 3



and asm:

	.file	"test.c"
	.section	.rodata
.LC0:
	.string	"asd"
	.text
.globl Myfunction
	.type	Myfunction, @function
Myfunction:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	movl	$.LC0, (%esp)
	call	printf__ml_stub
	leave
	ret
	.size	Myfunction, .-Myfunction
.globl main
	.type	main, @function
main:
	pushl	%ebp
	movl	%esp, %ebp
	subl	$8, %esp
	andl	$-16, %esp
	movl	$0, %eax
	addl	$15, %eax
	addl	$15, %eax
	shrl	$4, %eax
	sall	$4, %eax
	subl	%eax, %esp
	call	Myfunction
	movl	$0, %eax
	leave
	ret
	.size	main, .-main
	.ident	"GCC: (GNU) 4.0.2"
	.section	.note.GNU-stack,"",@progbits


so, the I still have Myfunction call instead of Myfunction__ml_stub,
which is quite annoying :-)

Who knows the ropes?

Thank you.


----- End forwarded message -----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]