summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2014-01-17 17:00:12 +0100
committerMark Wielaard <[email protected]>2014-01-23 11:31:53 +0100
commitced6687b6e41d008874e6f82209d0cecb79913fa (patch)
treed7f79e6e73ba088f8aef74025a42c33f2e7caa9e /libdwfl
parentc80375d5d61f44795f9650bdde08dab4c064c2b5 (diff)
robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/relocate.c9
2 files changed, 11 insertions, 3 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 55980a57..e55b03b7 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-17 Petr Machata <[email protected]>
+
+ * relocate.c (relocate_section): Use gelf_fsize instead of relying
+ on shdr->sh_entsize.
+
2014-01-05 Mark Wielaard <[email protected]>
* frame_unwind.c (handle_cfi): Only skip resetting return register
diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c
index f8a5fcfa..52b7b5eb 100644
--- a/libdwfl/relocate.c
+++ b/libdwfl/relocate.c
@@ -1,5 +1,5 @@
/* Relocate debug information.
- Copyright (C) 2005-2010 Red Hat, Inc.
+ Copyright (C) 2005-2011, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -456,7 +456,10 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr,
}
}
- size_t nrels = shdr->sh_size / shdr->sh_entsize;
+ size_t sh_entsize
+ = gelf_fsize (relocated, shdr->sh_type == SHT_REL ? ELF_T_REL : ELF_T_RELA,
+ 1, EV_CURRENT);
+ size_t nrels = shdr->sh_size / sh_entsize;
size_t complete = 0;
if (shdr->sh_type == SHT_REL)
for (size_t relidx = 0; !result && relidx < nrels; ++relidx)
@@ -558,7 +561,7 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr,
nrels = next;
}
- shdr->sh_size = reldata->d_size = nrels * shdr->sh_entsize;
+ shdr->sh_size = reldata->d_size = nrels * sh_entsize;
gelf_update_shdr (scn, shdr);
}