This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: detecting non-PIC in shared lib on Darwin?


On Apr 26, 2006, at 6:26 PM, Jack Howarth wrote:
readelf -d foo.so | grep TEXTREL

Does anyone know if some mechanism like this is possible for Darwin
shared libraries?

A man page is a terrible thing to waste:


-segprot name max init (32-bit only)
Specifies the maximum and initial virtual memory protection of
the named segment, name, to be max and init ,respectively. The
values for max and init are any combination of the characters
`r' (for read), `w' (for write), `x' (for execute) and '-' (no
access). The default is `rwx' for the maximum protection for
all segments for PowerPC architecures and `rw` for the all Intel
architecures. The default for the initial protection for all
segments is `rw' unless the segment contains a section which
contains some machine instructions, in which case the default
for the initial protection is `rwx' (and for Intel architecures
it also sets the maximum protection to `rwx' in this case). The
default for the initial protection for the ``__TEXT'' segment is
`rx' (not writable).


so, just add -segprot __TEXT rw rw to the -dynamiclib invocation.

I ask because we just discovered that the gmp developers
have been building non-PIC code (due to the usage of -fast without - fPIC)
in the MacOS X builds. It would be nice to be able to check for the non-PIC
code in all the shared libs on MacOS X. Thanks in advance for any info.

One cannot usually create a dynamic library with those relocations without this flag and will get a failed link. I'd anticipate that if something doesn't so warn, that is a bug.



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