I need some help for GCC optimization behavior which inserts call to
`memcpy` when
it detects that there is a structure variable assignment.
I have below sample code (copied from a similar gcc-help question):
[ 0] [15:21:40] root@localhost : # cat b.c
struct foo_t {
int x[1048576];
} *foo0, *foo1;
void bar(struct foo_t* foo)
{
*foo1 = *foo;
}
int main()
{
return 0;
}
# /usr/src/gcc-6.1.0/build/bin/gcc -fPIE -S b.c
This leads to GCC compiler issuing a call to `memcpy@PLT()' in function bar1.
I want to create a position independent executable from this source
and run this on
a secure environment which implements ASLR and the loader disallows any binary
which has PLT/GOT based relocations.
I have tried with option `-fno-tree-loop-distribute-patterns' but even
with this option,
if `-fPIE' flag is present I see that there is reference to `memcpy@PLT'.
I have even tried options like `-fno-plt' and
`-mstringop-strategy=loop' but I do not want
to use the output program generated with these options.
My problem is not with memcpy but with PLT portion; I want GCC to
generate reference
to `memcpy' (and not to `memcpy@PLT') in a position independent
executable when it
detects that there is structure variable assignment.
I have also tried by putting hidden visibility for this file but there
is same PLT
reference in this case also.
#pragma GCC visibility push(hidden)
Does GCC always insert call to `memcpy@PLT' for position independent
executables when
it detects that there is a structure variable assignment?
Is it possible to instruct GCC to insert `memcpy' with -fPIE flag for
structure variable assignments?
- GampuZ