Re: [PATCH] backends: sparc uses NONE relocation type in ET_EXEC and ET_DYN files
> Using the NONE relocation doesn't do anything, but is harmless. > > This fixes several (self) tests on sparc that use elflint to > check files are valid ELF. FWIW looks good to me. > > Signed-off-by: Mark Wielaard > --- > backends/ChangeLog | 4 > backends/sparc_reloc.def | 2 +- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/backends/ChangeLog b/backends/ChangeLog > index f28ab89b..40ec7c0c 100644 > --- a/backends/ChangeLog > +++ b/backends/ChangeLog > @@ -1,3 +1,7 @@ > +2023-01-19 Mark Wielaard > + > + * sparc_reloc.def (NONE): Add EXEC and DYN. > + > 2022-12-21 Shahab Vahedi > > * Makefile.am (modules): Add arc. > diff --git a/backends/sparc_reloc.def b/backends/sparc_reloc.def > index 7cd5ce96..f0eeb5c6 100644 > --- a/backends/sparc_reloc.def > +++ b/backends/sparc_reloc.def > @@ -28,7 +28,7 @@ > > /* NAME, REL|EXEC|DYN*/ > > -RELOC_TYPE (NONE, REL) > +RELOC_TYPE (NONE, REL|EXEC|DYN) > RELOC_TYPE (8, REL) > RELOC_TYPE (16, REL) > RELOC_TYPE (32, REL|DYN)
Re: [PATCHv2] strip: keep .ctf section in stripped file
> Hi, > > On Tue, 2022-12-20 at 22:35 +0100, Mark Wielaard wrote: >> On Wed, Jun 01, 2022 at 10:55:27AM -0500, Guillermo E. Martinez via >> Elfutils-devel wrote: >> > This is the second version patch to avoid remove the CTF section in >> > stripped files. Changes from v1: >> > >> > - Add description in tests/run-strip-remove-keep-ctf.sh >> > mentioning how to regenerate test input file (testfile-ctf) >> > >> > Please let me know your thoughts. >> > >> > [...] >> > >> > CTF debug format was designed to be present in stripped files, so >> > this section should not be removed, so a new --remove-ctf option >> > is added to indicate explicitly that .ctf section will be stripped >> > out from binary file. >> >> Sorry, I see I never reviewed this v2 variant. I know we tried to >> coordinate with binutils so eu-strip and binutils strip would do the >> same thing. And that Jose had an idea for a new section flag to >> automatically detect what section should/shouldn't be stripped (into a >> separate .debug file). What was the conclusion of that? > > Any update on this? > How should .ctf sections be dealt with by strip like tools? I think the conclusion was that having a NOSTRIP flag in the object file is far from trivial, because what "strip" means for several people and tools is not clear. So I guess we are stuck with the old keep-a-list method. Or we may add NOSTRIP meaning "_never ever_ strip this section, period, no matter what."
Re: [PATCH] strip: keep .ctf section in stripped file
[Added Nick in CC.] > Hi Guillermo, > > On Mon, May 30, 2022 at 09:26:19PM -0500, Guillermo E. Martinez via > Elfutils-devel wrote: >> Hello elfutils team, >> >> This patch is meant to avoid remove the CTF section in >> stripped files. Please let me know your thoughts. >> >> CTF debug format was designed to be present in stripped files, so >> this section should not be removed, so a new --remove-ctf option >> is added to indicate explicitly that .ctf section will be stripped >> out from binary file. > > First, very nice patch. My only real concern with it is that it should > describe how the testfile-ctf.bz2 is generated. We don't want really > random test binaries in the testsuite. There should be at least some > method to regenerate them, even if we don't automate that. See > e.g. tests/run-readelf-n.sh which also uses binary test files, but has > a little description on how each of them was generated. > > I am CCing Nick Clifton who works on binutils and annobin to check how > binutils strip handles this. And because we were recently discussing > putting some annobin data in a special section and how to indicate > that this section should be explicitly kept or removed. It would be > great if we could come to some kind of standard way of marking such > sections so we don't need special arguments for each such section or > at least have a more generic SECTION_STRIP_P macro. AFAIK the binutils `strip' does not strip .ctf sections. > Note, that this might not be possible, these sections might be to > different/specific that generalizing over them is impossible. But it > would be good to at least try and discuss it. If only so that elfutils > eu-strip and binutils strip agree on how to handle/coordinate on such > special sections. What about using an OS-specific section flag in elf.h, something like: #define SHF_GNU_PERSISTENT 0x0ff1 /* Section must not be stripped. */ > > Cheers, > > Mark > >> Signed-off-by: Guillermo E. Martinez >> --- >> ChangeLog | 23 >> libebl/eblsectionstripp.c | 4 +- >> libebl/libebl.h| 2 +- >> libelf/elf-knowledge.h | 7 +- >> libelf/elf32_checksum.c| 2 +- >> src/elfcmp.c | 4 +- >> src/strip.c| 71 -- >> tests/Makefile.am | 6 +- >> tests/run-strip-remove-keep-ctf.sh | 207 + >> tests/testfile-ctf.bz2 | Bin 0 -> 3317 bytes >> 10 files changed, 304 insertions(+), 22 deletions(-) >> create mode 100755 tests/run-strip-remove-keep-ctf.sh >> create mode 100755 tests/testfile-ctf.bz2 >> >> diff --git a/ChangeLog b/ChangeLog >> index f1a14b5c..2b608866 100644 >> --- a/ChangeLog >> +++ b/ChangeLog >> @@ -1,3 +1,26 @@ >> +2022-05-21 Guillermo E. Martinez >> + >> +* libebl/eblsectionstripp.c (ebl_section_strip_p): Use >> +remove_ctf argument. >> +(SECTION_STRIP_P): Likewise. >> +* libebl/libebl.h (ebl_section_strip_p): Likewise. >> +* libelf/elf-knowledge.h (SECTION_STRIP_P): Update macro >> +definition to use remove_ctf to determine whether .ctf >> +section is stripped out. >> +* libelf/elf32_checksum.c (elfw2): Use false value for >> +remove_ctf parameter. >> +* src/elfcmp.c (main): Likewise. >> +* src/strip.c (options): Add --remove-ctf option set by >> +remove_ctf variable. >> +(set_remove_special_section_opt): Add new function. >> +(erratic_special_section_opt): Likewise. >> +(parse_opt): Parse new --remove-ctf option. >> +(handle_elf): Adjust .comment and use remove_ctf argument. >> +* tests/Makefile.am (TEST): Add run-strip-remove-keep-ctf.sh >> +and testfile-ctf.bz2. >> +* tests/run-strip-remove-keep-ctf.sh: Add new testcase. >> +* tests/testfile-ctf.bz2: Add new test harness. >> + >> 2022-05-02 Mark Wielaard >> >> * Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Remove >> diff --git a/libebl/eblsectionstripp.c b/libebl/eblsectionstripp.c >> index a5624ffe..f26cc170 100644 >> --- a/libebl/eblsectionstripp.c >> +++ b/libebl/eblsectionstripp.c >> @@ -37,7 +37,7 @@ >> bool >> ebl_section_strip_p (Ebl *ebl, const GElf_Shdr *shdr, >> const char *name, bool remove_comment, >> - bool only_remove_debug) >> + bool only_remove_debug, bool remove_ctf) >> { >>/* If only debug information should be removed check the name. There >> is unfortunately no other way. */ >> @@ -66,5 +66,5 @@ ebl_section_strip_p (Ebl *ebl, const GElf_Shdr *shdr, >>return false; >> } >> >> - return SECTION_STRIP_P (shdr, name, remove_comment); >> + return SECTION_STRIP_P (shdr, name, remove_comment, remove_ctf); >> } >> diff --git a/libebl/libebl.h b/libebl/libebl.h >> index 731001d3..067b769e 100644 >> --- a/libebl/libebl.h >> +++ b/libebl/libebl.h >> @@ -205,7 +205,7 @@ extern bool ebl_relative_reloc_p (Ebl *ebl, int rel
Re: [PATCH] strip: keep .ctf section in stripped file
> [Added Nick in CC.] > >> Hi Guillermo, >> >> On Mon, May 30, 2022 at 09:26:19PM -0500, Guillermo E. Martinez via >> Elfutils-devel wrote: >>> Hello elfutils team, >>> >>> This patch is meant to avoid remove the CTF section in >>> stripped files. Please let me know your thoughts. >>> >>> CTF debug format was designed to be present in stripped files, so >>> this section should not be removed, so a new --remove-ctf option >>> is added to indicate explicitly that .ctf section will be stripped >>> out from binary file. >> >> First, very nice patch. My only real concern with it is that it should >> describe how the testfile-ctf.bz2 is generated. We don't want really >> random test binaries in the testsuite. There should be at least some >> method to regenerate them, even if we don't automate that. See >> e.g. tests/run-readelf-n.sh which also uses binary test files, but has >> a little description on how each of them was generated. >> >> I am CCing Nick Clifton who works on binutils and annobin to check how >> binutils strip handles this. And because we were recently discussing >> putting some annobin data in a special section and how to indicate >> that this section should be explicitly kept or removed. It would be >> great if we could come to some kind of standard way of marking such >> sections so we don't need special arguments for each such section or >> at least have a more generic SECTION_STRIP_P macro. >> >> Note, that this might not be possible, these sections might be to >> different/specific that generalizing over them is impossible. But it >> would be good to at least try and discuss it. If only so that elfutils >> eu-strip and binutils strip agree on how to handle/coordinate on such >> special sections. > > What about using an OS-specific section flag in elf.h, something like: > > #define SHF_GNU_PERSISTENT 0x0ff1 /* Section must not be stripped. */ It now occurs to me that it would be probably better to use a less abstract name for the flag, like SHF_GNU_NOSTRIP (I'm not that good on naming stuff.) :)
Re: [PATCH] strip: keep .ctf section in stripped file
> Hi Guys, > > I apologise - I know that Jose CC'ed me on this topic, but I have lost > the email, so I am creating this post instead. > >> What about using an OS-specific section flag in elf.h, something like: >> #define SHF_GNU_PERSISTENT 0x0ff1 /* Section must not be >> stripped. */ > > I rather like this idea. It would certainly make things easier. > Assuming that is that there is a convenient way to set the flag. Ie > we need to teach the assembler about it, and probably the linker too > (so that it can be used in linker scripts). > > It might also be a nice idea to have a complimentary flag to indicate > sections that expect to be stripped, even if they might otherwise be > retained. For example: > > #define SHF_GNU_TREAT_AS_DEBUG 0x0ff2 /* Treat as a debug info >section. Strip with other debug sections and move to a separate >debug info file when creating such files. */ > > This could be added to note sections for example, where the notes > will not be needed at run-time. I am, _very slowly_, working on this. Along with other 100 gazillion things to do, but unless someone else beats me to it, I will send patches at some point.