This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: GCC4.1.2, binutils 2.16.1, using “-fPIE -Wl,-pie”
- From: Nick Clifton <nickc at redhat dot com>
- To: dno gcc <dno dot gcc at gmail dot com>, binutils at sourceware dot org
- Date: Mon, 11 Nov 2019 14:51:45 +0000
- Subject: Re: GCC4.1.2, binutils 2.16.1, using “-fPIE -Wl,-pie”
- References: <CAEAjWv1OZQVG1N-yV5Cyyzvd6yE4CEGJGW1=MBS26HAFPXe=qg@mail.gmail.com>
Hi dno,
Are you really using gcc 4.1.2 and binutils 2.16.1 ? Those are
very old releases...
> Then, I have an mock of the function in the main.cpp, with the same
> name, and the difference is that it returns some other result, for
> example:
> unsigned long cFun1()
> {
> return 45;
> }
> So, in the main, I am calling the simple function like this:
> int main()
> {
> long retVal = cFun1();
>
> return 0;
> }
Is the mock version of cFun1() in the same file as main() ?
I am going to assume not, as otherwise you could just use #define
tricks to achieve what you want.
So, assuming that the real cFun1() is in a library, the mock
cFun1() is in an object file and main() is in a different object
file then you can probably achieve what you want by omitting the
-fvisibility=hidden from your gcc command line.
You should also check that both object files appear before the
library on the linker command line, so that the linker chooses
the version of cFun1 in the object file.
Cheers
Nick