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: GCC4.1.2, binutils 2.16.1, using “-fPIE -Wl,-pie”


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



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