Re: GCC4.1.2, binutils 2.16.1, using “-fPIE -Wl,-pie”

dno gcc dno.gcc@gmail.com
Wed Nov 20 13:38:00 GMT 2019


Hi Nick,
I am really using GCC4.1.2 and binutils 2.16.1, among other versions
of GCC and other versions of binutils. It is on an system for which
the maintenance is active. So, I am already using the
"-fvisibility=hidden" directive. I finally resolved the issue that I
was dealing with: I ended up analyzing the global offset table,
relocations, and the symbols in it and the .bss section for reading
out the start address of the virtual memory address ( I had few more
issues to solve ).

However, the situation was resolved, and the system is fully
functional as it should be.

Cheers,
dno

Am Mo., 11. Nov. 2019 um 15:51 Uhr schrieb Nick Clifton <nickc@redhat.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
>
>



More information about the Binutils mailing list