* How to tell if a ELF library/executable was built with -fpic versus -fPIC
@ 2022-01-02 16:06 Tom Kacvinsky
2022-01-04 6:52 ` Florian Weimer
0 siblings, 1 reply; 2+ messages in thread
From: Tom Kacvinsky @ 2022-01-02 16:06 UTC (permalink / raw)
To: gcc-help
Perhaps this belongs on the binutils list, but I'd like to know how if an ELF
library/executable was built with -fpic versus -fPIC. I know each makes PIC
object code, with the difference being the size of the data model:
-msmall-data (-fpic)
-mlarge-data (-fPIC)
but I have some shared libraries I am linking against such that I don't know
which PIC option was used to build it. Is there an ELF header I can check?
If this is the wrong list to post this, I will redirect to the binutils list.
Thanks,
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to tell if a ELF library/executable was built with -fpic versus -fPIC
2022-01-02 16:06 How to tell if a ELF library/executable was built with -fpic versus -fPIC Tom Kacvinsky
@ 2022-01-04 6:52 ` Florian Weimer
0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2022-01-04 6:52 UTC (permalink / raw)
To: Tom Kacvinsky via Gcc-help
* Tom Kacvinsky via Gcc-help:
> Perhaps this belongs on the binutils list, but I'd like to know how if an ELF
> library/executable was built with -fpic versus -fPIC. I know each makes PIC
> object code, with the difference being the size of the data model:
>
> -msmall-data (-fpic)
> -mlarge-data (-fPIC)
>
> but I have some shared libraries I am linking against such that I don't know
> which PIC option was used to build it. Is there an ELF header I can check?
It depends on the the concrete target. For a fully linked executable,
you'd have to disassemble it and check what is used for GOT access. For
relocatable object files, you can look at the relocations. There should
be an architecture-specific subset that can only handle a limited range,
and that set corresponds to -fpic.
There might be other options that affect the code model, with similar
consequences as the -fpic/-fPIC distinction.
Thanks,
Florian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-04 6:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-02 16:06 How to tell if a ELF library/executable was built with -fpic versus -fPIC Tom Kacvinsky
2022-01-04 6:52 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).