summaryrefslogtreecommitdiffstats
path: root/lib/libelf/elf_getbase.c
diff options
context:
space:
mode:
authorkaiw <kaiw@FreeBSD.org>2010-06-13 10:58:50 +0000
committerkaiw <kaiw@FreeBSD.org>2010-06-13 10:58:50 +0000
commit04e875d138b0f0687b75c3c2bd7ae8a22dfc293e (patch)
tree696bfa973f99aa4aead1ebdaac75cd47c02438cc /lib/libelf/elf_getbase.c
parent9100139edc3976c40b4dd05903c61be5c5fc333d (diff)
downloadFreeBSD-src-04e875d138b0f0687b75c3c2bd7ae8a22dfc293e.zip
FreeBSD-src-04e875d138b0f0687b75c3c2bd7ae8a22dfc293e.tar.gz
* Improve compatibility with existing application code by permitting the
use of `elf_getbase()` on non-archive members. This change is needed for gcc LTO (-flto) to work properly. * Style fix: paranthesize returned values. * Document the current behaviour of `elf_getbase()`. Tested by: gerald, Steve Kargl (original patch) Obtained from: elftoolchain MFC after: 3 days
Diffstat (limited to 'lib/libelf/elf_getbase.c')
-rw-r--r--lib/libelf/elf_getbase.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libelf/elf_getbase.c b/lib/libelf/elf_getbase.c
index d32fa6c..863c858 100644
--- a/lib/libelf/elf_getbase.c
+++ b/lib/libelf/elf_getbase.c
@@ -34,12 +34,14 @@ __FBSDID("$FreeBSD$");
off_t
elf_getbase(Elf *e)
{
- if (e == NULL ||
- e->e_parent == NULL) {
+ if (e == NULL) {
LIBELF_SET_ERROR(ARGUMENT, 0);
- return (off_t) -1;
+ return ((off_t) -1);
}
+ if (e->e_parent == NULL)
+ return ((off_t) 0);
+
return ((off_t) ((uintptr_t) e->e_rawfile -
(uintptr_t) e->e_parent->e_rawfile));
}
OpenPOWER on IntegriCloud