summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2020-12-01 09:38:54 +0100
committerMark Wielaard <mark@klomp.org>2020-12-06 14:36:59 +0100
commite917ef7ce9f55f8f0902310721ba7c76d6a67cad (patch)
tree9436dd9c85dcdc521397f1485c08a8bb6f70fbd2 /libdwfl
parentDrop $(EXEEXT) suffix from shared libraries (diff)
downloadelfutils-e917ef7ce9f55f8f0902310721ba7c76d6a67cad.tar.gz
elfutils-e917ef7ce9f55f8f0902310721ba7c76d6a67cad.tar.bz2
elfutils-e917ef7ce9f55f8f0902310721ba7c76d6a67cad.tar.xz
link_map: Inline consider_phdr() into only caller
This gets rid of the tested function and is shorter. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/link_map.c72
2 files changed, 37 insertions, 40 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 67a4d743..f11abb80 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
12020-12-01 Timm Bäder <tbaeder@redhat.com>
2
3 * link_map.c (dwfl_link_map_report): Removed consider_phdr function
4 and inline code.
5
12020-11-28 Mark Wielaard <mark@klomp.org> 62020-11-28 Mark Wielaard <mark@klomp.org>
2 7
3 * dwfl_segment_report_module.c (dwfl_segment_report_module): 8 * dwfl_segment_report_module.c (dwfl_segment_report_module):
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 29307c74..bcff8db5 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -758,31 +758,6 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
758 GElf_Xword dyn_filesz = 0; 758 GElf_Xword dyn_filesz = 0;
759 GElf_Addr dyn_bias = (GElf_Addr) -1; 759 GElf_Addr dyn_bias = (GElf_Addr) -1;
760 760
761 inline bool consider_phdr (GElf_Word type,
762 GElf_Addr vaddr, GElf_Xword filesz)
763 {
764 switch (type)
765 {
766 case PT_PHDR:
767 if (dyn_bias == (GElf_Addr) -1
768 /* Do a sanity check on the putative address. */
769 && ((vaddr & (dwfl->segment_align - 1))
770 == (phdr & (dwfl->segment_align - 1))))
771 {
772 dyn_bias = phdr - vaddr;
773 return dyn_vaddr != 0;
774 }
775 break;
776
777 case PT_DYNAMIC:
778 dyn_vaddr = vaddr;
779 dyn_filesz = filesz;
780 return dyn_bias != (GElf_Addr) -1;
781 }
782
783 return false;
784 }
785
786 if (phdr != 0 && phnum != 0) 761 if (phdr != 0 && phnum != 0)
787 { 762 {
788 Dwfl_Module *phdr_mod; 763 Dwfl_Module *phdr_mod;
@@ -895,22 +870,39 @@ dwfl_link_map_report (Dwfl *dwfl, const void *auxv, size_t auxv_size,
895 ? elf32_xlatetom : elf64_xlatetom) 870 ? elf32_xlatetom : elf64_xlatetom)
896 (&out, &in, elfdata) != NULL)) 871 (&out, &in, elfdata) != NULL))
897 { 872 {
898 /* We are looking for PT_DYNAMIC. */ 873 bool is32 = (elfclass == ELFCLASS32);
899 if (elfclass == ELFCLASS32) 874 for (size_t i = 0; i < phnum; ++i)
900 {
901 for (size_t i = 0; i < phnum; ++i)
902 if (consider_phdr ((*p32)[i].p_type,
903 (*p32)[i].p_vaddr,
904 (*p32)[i].p_filesz))
905 break;
906 }
907 else
908 { 875 {
909 for (size_t i = 0; i < phnum; ++i) 876 GElf_Word type = (is32
910 if (consider_phdr ((*p64)[i].p_type, 877 ? (*p32)[i].p_type
911 (*p64)[i].p_vaddr, 878 : (*p64)[i].p_type);
912 (*p64)[i].p_filesz)) 879 GElf_Addr vaddr = (is32
913 break; 880 ? (*p32)[i].p_vaddr
881 : (*p64)[i].p_vaddr);
882 GElf_Xword filesz = (is32
883 ? (*p32)[i].p_filesz
884 : (*p64)[i].p_filesz);
885
886 if (type == PT_PHDR)
887 {
888 if (dyn_bias == (GElf_Addr) -1
889 /* Do a sanity check on the putative address. */
890 && ((vaddr & (dwfl->segment_align - 1))
891 == (phdr & (dwfl->segment_align - 1))))
892 {
893 dyn_bias = phdr - vaddr;
894 if (dyn_vaddr != 0)
895 break;
896 }
897
898 }
899 else if (type == PT_DYNAMIC)
900 {
901 dyn_vaddr = vaddr;
902 dyn_filesz = filesz;
903 if (dyn_bias != (GElf_Addr) -1)
904 break;
905 }
914 } 906 }
915 } 907 }
916 908