Discussion:
DSO: library or PIE
Kirill A. Shutemov
2010-11-12 12:45:03 UTC
Permalink
Is there any easy way to detect whether DSO is PIE?

I only know about tricky heuristic:

http://git.altlinux.org/people/ldv/packages/rpm.git?p=rpm.git;a=blob;f=scripts/fixup-libraries
--
Kirill A. Shutemov
Roland McGrath
2010-11-12 22:30:03 UTC
Permalink
Post by Kirill A. Shutemov
Is there any easy way to detect whether DSO is PIE?
A PIE's dynamic section (SHT_DYNAMIC/PT_DYNAMIC) has a DT_DEBUG entry.
e.g. eu-readelf -d FILE | awk '$1 == "DEBUG" { exit 0 } END { exit 1 }'


Thanks,
Roland
Kirill A. Shutemov
2010-11-13 21:41:25 UTC
Permalink
Post by Roland McGrath
Post by Kirill A. Shutemov
Is there any easy way to detect whether DSO is PIE?
A PIE's dynamic section (SHT_DYNAMIC/PT_DYNAMIC) has a DT_DEBUG entry.
e.g. eu-readelf -d FILE | awk '$1 == "DEBUG" { exit 0 } END { exit 1 }'
Thanks. It seems works.

Does it specified in some spec or GNU ld just work so?
--
Kirill A. Shutemov
Roland McGrath
2010-11-15 23:26:51 UTC
Permalink
Post by Kirill A. Shutemov
Does it specified in some spec or GNU ld just work so?
PIE is not part of any formal specification.
It is a use already permitted by the generic ELF specification.

The essential meaning of a PIE is that it is an ET_DYN object that has an
e_entry address that works normally.

The presence of a DT_DEBUG is a necessary feature for the well-specified
techniques for debugging dynamically-linked executables to work normally.
Hence, a PIE has a DT_DEBUG.

Since PIE is a GNU invention, what we say it means is what the
specification is. We say it's an ET_DYN file with a DT_DEBUG entry.


Thanks,
Roland

Loading...