This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

Re: Safe Identical Code Folding for X86-64.


> Here is an example :
>
> int foo()
> {
>  return 1;
> }
>
> int bar()
> {
>  int (*p)() = foo;
>  p();
> }
>
> $ g++ -c test.cc
> $ readelf --relocs test.o
>
> Relocation section '.rela.text._Z3barv' at offset 0x660 contains 2 entries:
>  Offset          Info           Type           Sym. Value    Sym. Name +
> Addend 00000000000c  000a0000000b R_X86_64_32S      0000000000000000
> _Z3foov + 0 000000000011  000a00000002 R_X86_64_PC32     0000000000000000
> _Z3foov + fffffffffffffffc

You probably meant:

int foo()
{
 return 1;
}

int bar()
{
 int (*p)() = foo;
 foo ();
}

$ g++ -c test.cc -ffunction-sections

-- 
Eric Botcazou


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