mbox series

[v11,0/7] Support DT_RELR relative relocation format

Message ID 20220422190139.2615492-1-hjl.tools@gmail.com
Headers show
Series Support DT_RELR relative relocation format | expand

Message

H.J. Lu April 22, 2022, 7:01 p.m. UTC
Changes in v11:

1. Replace 

if (!(map)->l_info[DT_RELR])

with

if ((map)->l_info[DT_RELR] == NULL)

2. Add a space to --disable-default-dt-relr option.
3. Compile extra DT_RELR tests with $(no-stack-protector).
4. Add DT_RELR related macros to scripts/glibcelf.py.

Changes in v10:

1. Don't check GLIBC_PRIVATE definition for DT_RELR in ld.so since ld.so
has no DT_NEEDED entry.

Changes in v9:

1. A DT_RELR shared library without DT_NEEDED works.
2. A DT_RELR shared library without DT_VERNEED works.
3. A DT_RELR shared library without libc.so on DT_NEEDED works.

Changes in v8:

1. Remove the out-of-date comments in _dl_check_map_versions.
2. Change "long" to "long int".
3. Update the DT_RELR NEWS entry.

Changes in v7:

1. Add GLIBC_ABI_DT_RELR support before adding DT_RELR support.
2. Update the DT_RELR NEWS entry.
3. Misc fixes.

Changes in v6:

1. Move ELF_DYNAMIC_DO_RELR before ELF_DYNAMIC_DO_REL.

Changes in v5:

1. Update NEWS entry with the linker option, -z pack-relative-relocs.
2. Remove elf/libc-abi-version.exp and use $(READELF) to check
GLIBC_ABI_DT_RELR.

Changes in v4:

1. Always enable GLIBC_ABI_DT_RELR check.
2. Use $(OBJDUMP) instead of $(NM) for GLIBC_ABI_DT_RELR check. 

Changes in v3:

1. Don't define SUPPORT_DT_RELR.
2. Enable DT_RELR in glibc shared libraries and position independent
executables (PIE) automatically if linker supports -z pack-relative-relocs.

Changes in v2:

1. Enable DT_RELR for all targets.
2. Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR
dependency nor GLIBC_PRIVATE definition.

Fangrui Song (1):
  elf: Support DT_RELR relative relocation format [BZ #27924]

H.J. Lu (6):
  elf: Define DT_RELR related macros and types
  Add GLIBC_ABI_DT_RELR for DT_RELR support
  elf: Properly handle zero DT_RELA/DT_REL values
  elf: Add more DT_RELR tests
  Add --disable-default-dt-relr
  NEWS: Mention DT_RELR support

 INSTALL                |   6 +++
 Makeconfig             |  19 +++++++
 Makerules              |   2 +
 NEWS                   |   7 ++-
 configure              |  55 +++++++++++++++++++
 configure.ac           |  18 +++++++
 elf/Makefile           | 119 ++++++++++++++++++++++++++++++++++++++---
 elf/Versions           |   5 ++
 elf/dl-version.c       |  35 +++++++++++-
 elf/dynamic-link.h     |  40 +++++++++++++-
 elf/elf.h              |  13 ++++-
 elf/get-dynamic-info.h |  25 +++++++--
 elf/tst-relr-mod2.c    |  46 ++++++++++++++++
 elf/tst-relr-mod3a.c   |  49 +++++++++++++++++
 elf/tst-relr-mod3b.c   |  22 ++++++++
 elf/tst-relr-mod4a.c   |  19 +++++++
 elf/tst-relr-mod4b.c   |  19 +++++++
 elf/tst-relr-mod4b.map |   3 ++
 elf/tst-relr-pie.c     |   1 +
 elf/tst-relr.c         |  65 ++++++++++++++++++++++
 elf/tst-relr2.c        |  27 ++++++++++
 elf/tst-relr3.c        |  27 ++++++++++
 elf/tst-relr4.c        |   1 +
 include/link.h         |   2 +
 manual/install.texi    |   5 ++
 scripts/abilist.awk    |   2 +
 scripts/glibcelf.py    |   4 ++
 scripts/versions.awk   |   7 ++-
 28 files changed, 625 insertions(+), 18 deletions(-)
 create mode 100644 elf/tst-relr-mod2.c
 create mode 100644 elf/tst-relr-mod3a.c
 create mode 100644 elf/tst-relr-mod3b.c
 create mode 100644 elf/tst-relr-mod4a.c
 create mode 100644 elf/tst-relr-mod4b.c
 create mode 100644 elf/tst-relr-mod4b.map
 create mode 100644 elf/tst-relr-pie.c
 create mode 100644 elf/tst-relr.c
 create mode 100644 elf/tst-relr2.c
 create mode 100644 elf/tst-relr3.c
 create mode 100644 elf/tst-relr4.c

Comments

Adhemerval Zanella Netto April 25, 2022, 5:23 p.m. UTC | #1
On 22/04/2022 16:01, H.J. Lu wrote:
> Changes in v11:
> 
> 1. Replace 
> 
> if (!(map)->l_info[DT_RELR])
> 
> with
> 
> if ((map)->l_info[DT_RELR] == NULL)
> 
> 2. Add a space to --disable-default-dt-relr option.
> 3. Compile extra DT_RELR tests with $(no-stack-protector).
> 4. Add DT_RELR related macros to scripts/glibcelf.py.
> 
> Changes in v10:
> 
> 1. Don't check GLIBC_PRIVATE definition for DT_RELR in ld.so since ld.so
> has no DT_NEEDED entry.
> 
> Changes in v9:
> 
> 1. A DT_RELR shared library without DT_NEEDED works.
> 2. A DT_RELR shared library without DT_VERNEED works.
> 3. A DT_RELR shared library without libc.so on DT_NEEDED works.
> 
> Changes in v8:
> 
> 1. Remove the out-of-date comments in _dl_check_map_versions.
> 2. Change "long" to "long int".
> 3. Update the DT_RELR NEWS entry.
> 
> Changes in v7:
> 
> 1. Add GLIBC_ABI_DT_RELR support before adding DT_RELR support.
> 2. Update the DT_RELR NEWS entry.
> 3. Misc fixes.
> 
> Changes in v6:
> 
> 1. Move ELF_DYNAMIC_DO_RELR before ELF_DYNAMIC_DO_REL.
> 
> Changes in v5:
> 
> 1. Update NEWS entry with the linker option, -z pack-relative-relocs.
> 2. Remove elf/libc-abi-version.exp and use $(READELF) to check
> GLIBC_ABI_DT_RELR.
> 
> Changes in v4:
> 
> 1. Always enable GLIBC_ABI_DT_RELR check.
> 2. Use $(OBJDUMP) instead of $(NM) for GLIBC_ABI_DT_RELR check. 
> 
> Changes in v3:
> 
> 1. Don't define SUPPORT_DT_RELR.
> 2. Enable DT_RELR in glibc shared libraries and position independent
> executables (PIE) automatically if linker supports -z pack-relative-relocs.
> 
> Changes in v2:
> 
> 1. Enable DT_RELR for all targets.
> 2. Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR
> dependency nor GLIBC_PRIVATE definition.
> 
> Fangrui Song (1):
>   elf: Support DT_RELR relative relocation format [BZ #27924]

The patchset looks ok, the only piece that I think it does not add much and
it would be better to be dropped is the '--disable-default-dt-relr' support.

As we discussed in the weekly patchset call, having less configure switches
is desirable and this specific option will most likely not be used.
H.J. Lu April 26, 2022, 3:39 p.m. UTC | #2
On Mon, Apr 25, 2022 at 10:23 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 22/04/2022 16:01, H.J. Lu wrote:
> > Changes in v11:
> >
> > 1. Replace
> >
> > if (!(map)->l_info[DT_RELR])
> >
> > with
> >
> > if ((map)->l_info[DT_RELR] == NULL)
> >
> > 2. Add a space to --disable-default-dt-relr option.
> > 3. Compile extra DT_RELR tests with $(no-stack-protector).
> > 4. Add DT_RELR related macros to scripts/glibcelf.py.
> >
> > Changes in v10:
> >
> > 1. Don't check GLIBC_PRIVATE definition for DT_RELR in ld.so since ld.so
> > has no DT_NEEDED entry.
> >
> > Changes in v9:
> >
> > 1. A DT_RELR shared library without DT_NEEDED works.
> > 2. A DT_RELR shared library without DT_VERNEED works.
> > 3. A DT_RELR shared library without libc.so on DT_NEEDED works.
> >
> > Changes in v8:
> >
> > 1. Remove the out-of-date comments in _dl_check_map_versions.
> > 2. Change "long" to "long int".
> > 3. Update the DT_RELR NEWS entry.
> >
> > Changes in v7:
> >
> > 1. Add GLIBC_ABI_DT_RELR support before adding DT_RELR support.
> > 2. Update the DT_RELR NEWS entry.
> > 3. Misc fixes.
> >
> > Changes in v6:
> >
> > 1. Move ELF_DYNAMIC_DO_RELR before ELF_DYNAMIC_DO_REL.
> >
> > Changes in v5:
> >
> > 1. Update NEWS entry with the linker option, -z pack-relative-relocs.
> > 2. Remove elf/libc-abi-version.exp and use $(READELF) to check
> > GLIBC_ABI_DT_RELR.
> >
> > Changes in v4:
> >
> > 1. Always enable GLIBC_ABI_DT_RELR check.
> > 2. Use $(OBJDUMP) instead of $(NM) for GLIBC_ABI_DT_RELR check.
> >
> > Changes in v3:
> >
> > 1. Don't define SUPPORT_DT_RELR.
> > 2. Enable DT_RELR in glibc shared libraries and position independent
> > executables (PIE) automatically if linker supports -z pack-relative-relocs.
> >
> > Changes in v2:
> >
> > 1. Enable DT_RELR for all targets.
> > 2. Issue an error if there is a DT_RELR entry without GLIBC_ABI_DT_RELR
> > dependency nor GLIBC_PRIVATE definition.
> >
> > Fangrui Song (1):
> >   elf: Support DT_RELR relative relocation format [BZ #27924]
>
> The patchset looks ok, the only piece that I think it does not add much and
> it would be better to be dropped is the '--disable-default-dt-relr' support.
>
> As we discussed in the weekly patchset call, having less configure switches
> is desirable and this specific option will most likely not be used.

I will drop the -disable-default-dt-relr patch, rebase and check them in.

Thanks.