* [PATCH 1/2] libelf: Sync elf.h from glibc.
@ 2020-12-12 22:38 Mark Wielaard
2020-12-12 22:38 ` [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint Mark Wielaard
2020-12-16 10:44 ` [PATCH 1/2] libelf: Sync elf.h from glibc Dmitry V. Levin
0 siblings, 2 replies; 6+ messages in thread
From: Mark Wielaard @ 2020-12-12 22:38 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
Adds SHF_GNU_RETAIN.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/ChangeLog | 4 ++++
libelf/elf.h | 13 +++++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 41727fbd..2d8bbe5d 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2020-12-12 Mark Wielaard <mark@klomp.org>
+
+ * elf.h: Update from glibc.
+
2020-12-12 Dmitry V. Levin <ldv@altlinux.org>
* common.h: Fix spelling typo in comment.
diff --git a/libelf/elf.h b/libelf/elf.h
index 6439c1a4..8e3e618f 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -318,7 +318,7 @@ typedef struct
/* reserved 184 */
#define EM_AVR32 185 /* Amtel 32-bit microprocessor */
#define EM_STM8 186 /* STMicroelectronics STM8 */
-#define EM_TILE64 187 /* Tileta TILE64 */
+#define EM_TILE64 187 /* Tilera TILE64 */
#define EM_TILEPRO 188 /* Tilera TILEPro */
#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
#define EM_CUDA 190 /* NVIDIA CUDA */
@@ -441,7 +441,7 @@ typedef struct
#define SHT_FINI_ARRAY 15 /* Array of destructors */
#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
#define SHT_GROUP 17 /* Section group */
-#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
+#define SHT_SYMTAB_SHNDX 18 /* Extended section indices */
#define SHT_NUM 19 /* Number of defined types. */
#define SHT_LOOS 0x60000000 /* Start OS-specific. */
#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
@@ -478,6 +478,7 @@ typedef struct
#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
+#define SHF_GNU_RETAIN (1 << 21) /* Not to be GCed by linker. */
#define SHF_ORDERED (1 << 30) /* Special ordering requirement
(Solaris). */
#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
@@ -1046,7 +1047,7 @@ typedef struct
#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
-/* Auxialiary version information. */
+/* Auxiliary version information. */
typedef struct
{
@@ -2139,9 +2140,9 @@ enum
#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
-/* Additional section indeces. */
+/* Additional section indices. */
-#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
+#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tentatively declared
symbols in ANSI C. */
#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
@@ -3970,7 +3971,7 @@ enum
#define R_METAG_RELBRANCH 4
#define R_METAG_GETSETOFF 5
-/* Backward compatability */
+/* Backward compatibility */
#define R_METAG_REG32OP1 6
#define R_METAG_REG32OP2 7
#define R_METAG_REG32OP3 8
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint.
2020-12-12 22:38 [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
@ 2020-12-12 22:38 ` Mark Wielaard
2020-12-16 10:49 ` Dmitry V. Levin
2020-12-16 10:44 ` [PATCH 1/2] libelf: Sync elf.h from glibc Dmitry V. Levin
1 sibling, 1 reply; 6+ messages in thread
From: Mark Wielaard @ 2020-12-12 22:38 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
readelf -S now shows 'R' when SHF_GNU_RETAIN is set.
elflint accepts SHF_GNU_RETAIN when set on section in --gnu mode.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 5 ++++
src/elflint.c | 3 +++
src/readelf.c | 2 ++
tests/ChangeLog | 7 ++++++
tests/Makefile.am | 2 ++
tests/run-retain.sh | 44 ++++++++++++++++++++++++++++++++++++
tests/testfile-retain.o.bz2 | Bin 0 -> 261 bytes
7 files changed, 63 insertions(+)
create mode 100755 tests/run-retain.sh
create mode 100644 tests/testfile-retain.o.bz2
diff --git a/src/ChangeLog b/src/ChangeLog
index f5a02a36..e6ff981f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2020-12-12 Mark Wielaard <mark@klomp.org>
+
+ * elflint.c (check_sections): Handle SHF_GNU_RETAIN.
+ * readelf.c (print_shdr): Likewise.
+
2020-12-12 Dmitry V. Levin <ldv@altlinux.org>
* ar.c (write_member, do_oper_insert): Fix spelling typo in comment.
diff --git a/src/elflint.c b/src/elflint.c
index 6e219ced..6ca1879e 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -3935,6 +3935,9 @@ section [%2zu] '%s': size not multiple of entry size\n"),
cnt, section_name (ebl, cnt), sh_flags & SHF_MASKPROC);
sh_flags &= ~(GElf_Xword) SHF_MASKPROC;
}
+ if (sh_flags & SHF_MASKOS)
+ if (gnuld)
+ sh_flags &= ~(GElf_Xword) SHF_GNU_RETAIN;
if (sh_flags != 0)
ERROR (gettext ("section [%2zu] '%s' contains unknown flag(s)"
" %#" PRIx64 "\n"),
diff --git a/src/readelf.c b/src/readelf.c
index f51b41d7..dbb0c73f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1298,6 +1298,8 @@ There are %zd section headers, starting at offset %#" PRIx64 ":\n\
*cp++ = 'O';
if (shdr->sh_flags & SHF_EXCLUDE)
*cp++ = 'E';
+ if (shdr->sh_flags & SHF_GNU_RETAIN)
+ *cp++ = 'R';
*cp = '\0';
const char *sname;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2c83f690..cb6d5f8b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2020-12-12 Mark Wielaard <mark@klomp.org>
+
+ * testfile-retain.o.bz2: New test file.
+ * run-retain.sh: New test.
+ * Makefile.am (TESTS): Add run-retain.sh.
+ (EXTRA_DIST): Add run-retain.sh and testfile-retain.o.bz2
+
2020-12-12 Dmitry V. Levin <ldv@altlinux.org>
* dwarf-die-addr-die.c (main): Fix spelling typo in error diagnostics.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3cca2251..502becff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -125,6 +125,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
run-readelf-aranges.sh run-readelf-line.sh run-readelf-z.sh \
run-readelf-frames.sh \
run-readelf-n.sh \
+ run-retain.sh \
run-native-test.sh run-bug1-test.sh \
run-debuglink.sh run-debugaltlink.sh run-buildid.sh \
dwfl-bug-addr-overflow run-addrname-test.sh \
@@ -318,6 +319,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
testfile_gnu_props.32be.o.bz2 \
testfile_gnu_props.64be.o.bz2 \
testfile-gnu-property-note-aarch64.bz2 \
+ run-retain.sh testfile-retain.o.bz2 \
run-allfcts-multi.sh \
test-offset-loop.bz2 test-offset-loop.alt.bz2 \
run-prelink-addr-test.sh \
diff --git a/tests/run-retain.sh b/tests/run-retain.sh
new file mode 100755
index 00000000..c5376de4
--- /dev/null
+++ b/tests/run-retain.sh
@@ -0,0 +1,44 @@
+# Copyright (C) 2020 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# elfutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# - retian.s
+# .section .data.retain,"R"
+# .word 1
+#
+# as -o testfile-retain.o retain.s
+
+testfiles testfile-retain.o
+
+testrun_compare ${abs_top_builddir}/src/readelf -S testfile-retain.o << EOF
+There are 9 section headers, starting at offset 0x158:
+
+Section Headers:
+[Nr] Name Type Addr Off Size ES Flags Lk Inf Al
+[ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0
+[ 1] .text PROGBITS 0000000000000000 00000040 00000000 0 AX 0 0 1
+[ 2] .data PROGBITS 0000000000000000 00000040 00000000 0 WA 0 0 1
+[ 3] .bss NOBITS 0000000000000000 00000040 00000000 0 WA 0 0 1
+[ 4] .data.retain PROGBITS 0000000000000000 00000040 00000002 0 WAR 0 0 1
+[ 5] .note.gnu.property NOTE 0000000000000000 00000048 00000030 0 A 0 0 8
+[ 6] .symtab SYMTAB 0000000000000000 00000078 00000090 24 7 6 8
+[ 7] .strtab STRTAB 0000000000000000 00000108 00000001 0 0 0 1
+[ 8] .shstrtab STRTAB 0000000000000000 00000109 0000004c 0 0 0 1
+
+EOF
+
+testrun ${abs_top_builddir}/src/elflint --gnu testfile-retain.o
diff --git a/tests/testfile-retain.o.bz2 b/tests/testfile-retain.o.bz2
new file mode 100644
index 0000000000000000000000000000000000000000..7571c0ec934a51be7f272c3467de561524c50a32
GIT binary patch
literal 261
zcmV+g0s8(zT4*^jL0KkKStGCDz5oE<|D=EDs7T<2Kp{iL0zfw7-eAB0KmafR)-Z@Q
zGL4iN1Tr#U36YGU6!IaEH8f#8Gz7>R8fd^`DKs)^qb7g>riOqt3m_5KgZ2MQk4jJ4
zh8>_%0mBd|j3Q*j(eyIdzEV0sH|Wan048W(Qp2T)CPgv?lODO8iQ{1Ouq=QHBmkEa
z5KF48v(08GM3FUeZls|BNaLQ>*bJzSNzoN&0e~Npg^5T+hZkl<5a^eoi<EmNNMK1)
zgG~X+$Xj8B?7n8Xz?ug_XhX54JuYRq?3&sj>!IC4VOU*xf|_0mM-Uafg}EI51Ngg=
LDZ+$-9e)Mz^L20Z
literal 0
HcmV?d00001
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint.
2020-12-12 22:38 ` [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint Mark Wielaard
@ 2020-12-16 10:49 ` Dmitry V. Levin
2020-12-16 18:53 ` Mark Wielaard
0 siblings, 1 reply; 6+ messages in thread
From: Dmitry V. Levin @ 2020-12-16 10:49 UTC (permalink / raw)
To: elfutils-devel
On Sat, Dec 12, 2020 at 11:38:55PM +0100, Mark Wielaard wrote:
> readelf -S now shows 'R' when SHF_GNU_RETAIN is set.
> elflint accepts SHF_GNU_RETAIN when set on section in --gnu mode.
>
> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
> src/ChangeLog | 5 ++++
> src/elflint.c | 3 +++
> src/readelf.c | 2 ++
> tests/ChangeLog | 7 ++++++
> tests/Makefile.am | 2 ++
> tests/run-retain.sh | 44 ++++++++++++++++++++++++++++++++++++
> tests/testfile-retain.o.bz2 | Bin 0 -> 261 bytes
> 7 files changed, 63 insertions(+)
> create mode 100755 tests/run-retain.sh
> create mode 100644 tests/testfile-retain.o.bz2
LGTM, thanks,
--
ldv
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint.
2020-12-16 10:49 ` Dmitry V. Levin
@ 2020-12-16 18:53 ` Mark Wielaard
0 siblings, 0 replies; 6+ messages in thread
From: Mark Wielaard @ 2020-12-16 18:53 UTC (permalink / raw)
To: Dmitry V. Levin; +Cc: elfutils-devel
On Wed, Dec 16, 2020 at 01:49:30PM +0300, Dmitry V. Levin wrote:
> On Sat, Dec 12, 2020 at 11:38:55PM +0100, Mark Wielaard wrote:
> > readelf -S now shows 'R' when SHF_GNU_RETAIN is set.
> > elflint accepts SHF_GNU_RETAIN when set on section in --gnu mode.
> >
> > Signed-off-by: Mark Wielaard <mark@klomp.org>
> > ---
> > src/ChangeLog | 5 ++++
> > src/elflint.c | 3 +++
> > src/readelf.c | 2 ++
> > tests/ChangeLog | 7 ++++++
> > tests/Makefile.am | 2 ++
> > tests/run-retain.sh | 44 ++++++++++++++++++++++++++++++++++++
> > tests/testfile-retain.o.bz2 | Bin 0 -> 261 bytes
> > 7 files changed, 63 insertions(+)
> > create mode 100755 tests/run-retain.sh
> > create mode 100644 tests/testfile-retain.o.bz2
>
> LGTM, thanks,
Thanks, pushed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] libelf: Sync elf.h from glibc.
2020-12-12 22:38 [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
2020-12-12 22:38 ` [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint Mark Wielaard
@ 2020-12-16 10:44 ` Dmitry V. Levin
2020-12-16 18:52 ` Mark Wielaard
1 sibling, 1 reply; 6+ messages in thread
From: Dmitry V. Levin @ 2020-12-16 10:44 UTC (permalink / raw)
To: elfutils-devel
On Sat, Dec 12, 2020 at 11:38:54PM +0100, Mark Wielaard wrote:
> Adds SHF_GNU_RETAIN.
This is obviously OK.
--
ldv
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-16 18:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-12 22:38 [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
2020-12-12 22:38 ` [PATCH 2/2] Handle SHF_GNU_RETAIN in eu-readelf and eu-elflint Mark Wielaard
2020-12-16 10:49 ` Dmitry V. Levin
2020-12-16 18:53 ` Mark Wielaard
2020-12-16 10:44 ` [PATCH 1/2] libelf: Sync elf.h from glibc Dmitry V. Levin
2020-12-16 18:52 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).