[PATCH] backends: COPY relocations can also happen in ET_DYN.
by Mark Wielaard
In particular COPY relocations might happen in PIE executables,
which are ET_DYN.
Found on Fedora Rawhide with run-elflint-self.sh.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
backends/ChangeLog | 14 ++++++++++++++
backends/aarch64_reloc.def | 4 ++--
backends/arm_reloc.def | 4 ++--
backends/i386_reloc.def | 4 ++--
backends/ia64_reloc.def | 4 ++--
backends/ppc64_reloc.def | 4 ++--
backends/ppc_reloc.def | 4 ++--
backends/s390_reloc.def | 4 ++--
backends/sh_reloc.def | 4 ++--
backends/sparc_reloc.def | 4 ++--
backends/tilegx_reloc.def | 3 ++-
backends/x86_64_reloc.def | 4 ++--
12 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 9f5975a..818e8d5 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,17 @@
+2015-03-09 Mark Wielaard <mjw(a)redhat.com>
+
+ * aarch64_reloc.def (COPY): Add DYN.
+ * arm_reloc.def (COPY): Likewise.
+ * i386_reloc.def (COPY): Likewise.
+ * ia64_reloc.def (COPY): Likewise.
+ * ppc64_reloc.def (COPY): Likewise.
+ * ppc_reloc.def (COPY): Likewise.
+ * s390_reloc.def (COPY): Likewise.
+ * sh_reloc.def (COPY): Likewise.
+ * sparc_reloc.def (COPY): Likewise.
+ * tilegx_reloc.def (COPY): Likewise.
+ * x86_64_reloc.def (COPY): Likewise.
+
2015-02-23 Petr Machata <pmachata(a)redhat.com>
* arm_symbol.c (arm_symbol_type_name): New function.
diff --git a/backends/aarch64_reloc.def b/backends/aarch64_reloc.def
index 36d29e6..2e16e98 100644
--- a/backends/aarch64_reloc.def
+++ b/backends/aarch64_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for AArch64. -*- C -*-
- Copyright (C) 2013, 2014 Red Hat, Inc.
+ Copyright (C) 2013, 2014, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@
RELOC_TYPE (ABS64, REL|EXEC|DYN)
RELOC_TYPE (ABS32, REL|EXEC|DYN)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JUMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/arm_reloc.def b/backends/arm_reloc.def
index 4b7894b..113648e 100644
--- a/backends/arm_reloc.def
+++ b/backends/arm_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for arm. -*- C -*-
- Copyright (C) 2005-2010, 2014 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2014, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@ RELOC_TYPE (THM_XPC22, REL)
RELOC_TYPE (TLS_DTPMOD32, EXEC|DYN)
RELOC_TYPE (TLS_DTPOFF32, EXEC|DYN)
RELOC_TYPE (TLS_TPOFF32, EXEC|DYN)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JUMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/i386_reloc.def b/backends/i386_reloc.def
index bd273b3..de3575d 100644
--- a/backends/i386_reloc.def
+++ b/backends/i386_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for i386. -*- C -*-
- Copyright (C) 2000, 2001, 2002, 2003, 2005, 2009 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2005, 2009, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -29,7 +29,7 @@
/* NAME, REL|EXEC|DYN */
RELOC_TYPE (NONE, 0)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (32, REL|EXEC|DYN)
RELOC_TYPE (PC32, REL|EXEC|DYN)
RELOC_TYPE (GOT32, REL)
diff --git a/backends/ia64_reloc.def b/backends/ia64_reloc.def
index 9e058c8..2428925 100644
--- a/backends/ia64_reloc.def
+++ b/backends/ia64_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for ia64. -*- C -*-
- Copyright (C) 2005, 2006 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -88,7 +88,7 @@ RELOC_TYPE (PCREL22, REL)
RELOC_TYPE (PCREL64I, REL)
RELOC_TYPE (IPLTMSB, REL|EXEC|DYN)
RELOC_TYPE (IPLTLSB, REL|EXEC|DYN)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (SUB, 0)
RELOC_TYPE (LTOFF22X, REL)
RELOC_TYPE (LDXMOV, REL)
diff --git a/backends/ppc64_reloc.def b/backends/ppc64_reloc.def
index 3a693cf..15a73ba 100644
--- a/backends/ppc64_reloc.def
+++ b/backends/ppc64_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for ppc64. -*- C -*-
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -46,7 +46,7 @@ RELOC_TYPE (GOT16, REL)
RELOC_TYPE (GOT16_LO, REL)
RELOC_TYPE (GOT16_HI, REL)
RELOC_TYPE (GOT16_HA, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/ppc_reloc.def b/backends/ppc_reloc.def
index dc963a0..3723a9c 100644
--- a/backends/ppc_reloc.def
+++ b/backends/ppc_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for ppc. -*- C -*-
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -47,7 +47,7 @@ RELOC_TYPE (GOT16_LO, REL)
RELOC_TYPE (GOT16_HI, REL)
RELOC_TYPE (GOT16_HA, REL)
RELOC_TYPE (PLTREL24, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/s390_reloc.def b/backends/s390_reloc.def
index b4686a3..cdef9eb 100644
--- a/backends/s390_reloc.def
+++ b/backends/s390_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for s390. -*- C -*-
- Copyright (C) 2005, 2006 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -37,7 +37,7 @@ RELOC_TYPE (PC32, REL|EXEC|DYN)
RELOC_TYPE (GOT12, REL)
RELOC_TYPE (GOT32, REL)
RELOC_TYPE (PLT32, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/sh_reloc.def b/backends/sh_reloc.def
index 66a5a9d..aded361 100644
--- a/backends/sh_reloc.def
+++ b/backends/sh_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for SH. -*- C -*-
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -59,7 +59,7 @@ RELOC_TYPE (TLS_DTPOFF32, DYN)
RELOC_TYPE (TLS_TPOFF32, DYN)
RELOC_TYPE (GOT32, REL)
RELOC_TYPE (PLT32, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/sparc_reloc.def b/backends/sparc_reloc.def
index c39b0fa..2aeb129 100644
--- a/backends/sparc_reloc.def
+++ b/backends/sparc_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for sparc. -*- C -*-
- Copyright (C) 2009 Red Hat, Inc.
+ Copyright (C) 2009, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -47,7 +47,7 @@ RELOC_TYPE (GOT22, REL)
RELOC_TYPE (PC10, REL)
RELOC_TYPE (PC22, REL)
RELOC_TYPE (WPLT30, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/tilegx_reloc.def b/backends/tilegx_reloc.def
index 9736286..1018110 100644
--- a/backends/tilegx_reloc.def
+++ b/backends/tilegx_reloc.def
@@ -1,5 +1,6 @@
/* List the relocation types for tilegx. -*- C -*-
Copyright (C) 2012 Tilera Corporation
+ Copyright (C) 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -44,7 +45,7 @@ RELOC_TYPE (HW3, REL)
RELOC_TYPE (HW0_LAST, REL)
RELOC_TYPE (HW1_LAST, REL)
RELOC_TYPE (HW2_LAST, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
diff --git a/backends/x86_64_reloc.def b/backends/x86_64_reloc.def
index 8ed98f6..ad84efa 100644
--- a/backends/x86_64_reloc.def
+++ b/backends/x86_64_reloc.def
@@ -1,5 +1,5 @@
/* List the relocation types for x86-64. -*- C -*-
- Copyright (C) 2000, 2001, 2002, 2003, 2005, 2009 Red Hat, Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2005, 2009, 2015 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -33,7 +33,7 @@ RELOC_TYPE (64, REL|EXEC|DYN)
RELOC_TYPE (PC32, REL|EXEC|DYN)
RELOC_TYPE (GOT32, REL)
RELOC_TYPE (PLT32, REL)
-RELOC_TYPE (COPY, EXEC)
+RELOC_TYPE (COPY, EXEC|DYN)
RELOC_TYPE (GLOB_DAT, EXEC|DYN)
RELOC_TYPE (JUMP_SLOT, EXEC|DYN)
RELOC_TYPE (RELATIVE, EXEC|DYN)
--
1.8.3.1
9 years
[PATCH] elflint: Correct gnu_symbias usage in compare_hash_gnu_hash.
by Mark Wielaard
commit 0a545e "elflint: Add various low-level checks." introduced a bug
in the handling of the gnu_symbias. The symbol in the bucket should first
be compared to STN_UNDEF before applying the bias. And the used symbol
index should have the bias added when compared against plain hash symbol.
Found on Debian wheezy with run-elflint-self.sh.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/elflint.c | 30 ++++++++++++++++--------------
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index dad984e..bb9580a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-09 Mark Wielaard <mjw(a)redhat.com>
+
+ * elflint.c (compare_hash_gnu_hash): Correct gnu_symbias usage.
+
2015-01-03 Mark Wielaard <mjw(a)redhat.com>
* elfcmp (main): Check section name is not NULL. Check sh_entsize
diff --git a/src/elflint.c b/src/elflint.c
index 143424c..a6f9b68 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -2397,20 +2397,22 @@ hash section [%2zu] '%s' uses too much data\n"),
for (Elf32_Word cnt = 0; cnt < gnu_nbucket; ++cnt)
{
- Elf32_Word symidx = gnu_bucket[cnt] - gnu_symbias;;
- if (symidx != STN_UNDEF)
- do
- {
- if (symidx >= max_nsyms || symidx >= nentries)
- {
- ERROR (gettext ("\
-hash section [%2zu] '%s' invalid symbol index\n"),
- gnu_hash_idx, gnu_hash_name);
- return;
- }
- used[symidx] |= 1;
- }
- while ((gnu_chain[symidx++] & 1u) == 0);
+ if (gnu_bucket[cnt] != STN_UNDEF)
+ {
+ Elf32_Word symidx = gnu_bucket[cnt] - gnu_symbias;
+ do
+ {
+ if (symidx >= max_nsyms || symidx + gnu_symbias >= nentries)
+ {
+ ERROR (gettext ("\
+hash section [%2zu] '%s' invalid symbol index %" PRIu32 " (max_nsyms: %" PRIu32 ", nentries: %" PRIu32 "\n"),
+ gnu_hash_idx, gnu_hash_name, symidx, max_nsyms, nentries);
+ return;
+ }
+ used[symidx + gnu_symbias] |= 1;
+ }
+ while ((gnu_chain[symidx++] & 1u) == 0);
+ }
}
/* Now go over the old hash table and check that we cover the same
--
1.8.3.1
9 years
[PATCH] Fix section corruption bug
by Thilo Schulz
Hi,
When adding data to existing sections in ELF files, libelf may corrupt
those sections, i.e. overwrite the existing data if certain conditions are
met.
If an Elf_Scn structure has seen a call to elf_rawdata(scn) before but no
call to elf_getdata(scn), scn->read_data flag is set, but not
scn->data_list_rear.
Thus, elf_newdata(scn) incorrectly detects a "new user added section" when
really it is a section with live, valid data that will be overwritten by
elf_update(), corrupting the section.
This patch fixes this incorrect behaviour.
Signed-off-by: Thilo Schulz <thilo(a)tjps.eu>
---
libelf/elf_newdata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libelf/elf_newdata.c b/libelf/elf_newdata.c
index 90d1813..f90eb0a 100644
--- a/libelf/elf_newdata.c
+++ b/libelf/elf_newdata.c
@@ -64,7 +64,7 @@ elf_newdata (Elf_Scn *scn)
rwlock_wrlock (scn->elf->lock);
- if (scn->data_read && scn->data_list_rear == NULL)
+ if (scn->data_read && scn->data_list_rear == NULL && !scn->rawdata.s)
{
/* This means the section was created by the user and this is the
first data. */
--
1.7.10.4
9 years
[PATCH] Drop two useless variables from known-dwarf.awk
by Petr Machata
Signed-off-by: Petr Machata <pmachata(a)redhat.com>
---
config/ChangeLog | 5 +++++
config/known-dwarf.awk | 11 ++---------
2 files changed, 7 insertions(+), 9 deletions(-)
mode change 100644 => 100755 config/known-dwarf.awk
diff --git a/config/ChangeLog b/config/ChangeLog
index 1b4e896..409e2b1 100644
--- a/config/ChangeLog
+++ b/config/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-20 Petr Machata <pmachata(a)redhat.com>
+
+ * known-dwarf.awk (END): Drop useless variables lo, hi. Merge two
+ continue-checks in one.
+
2014-12-18 Mark Wielaard <mjw(a)redhat.com>
* elfutils.spec.in: Update for 0.161.
diff --git a/config/known-dwarf.awk b/config/known-dwarf.awk
old mode 100644
new mode 100755
index 52ec5b6..4d89f0f
--- a/config/known-dwarf.awk
+++ b/config/known-dwarf.awk
@@ -1,6 +1,6 @@
#!/bin/gawk -f
-## Copyright (C) 2012 Red Hat, Inc.
+## Copyright (C) 2012, 2015 Red Hat, Inc.
##
## This file is part of elfutils.
##
@@ -48,19 +48,12 @@ END {
if (what && what != set) continue;
split(DW[set], elts, ",");
m = asort(elts);
- lo = hi = "";
if (m == 0) continue;
print "\n#define ALL_KNOWN_DW_" set " \\";
for (j = 1; j <= m; ++j) {
elt = elts[j];
- if (elt ~ /(lo|low)_user$/) {
- lo = elt;
+ if (elt ~ /(low?|hi|high)_user$/)
continue;
- }
- if (elt ~ /(hi|high)_user$/) {
- hi = elt;
- continue;
- }
if (comment[set, elt])
print " ONE_KNOWN_DW_" set "_DESC (" elt ", DW_" set "_" elt \
", \"" comment[set, elt] "\") \\";
--
2.1.0
9 years