From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 376E93858C53 for ; Thu, 24 Aug 2023 19:40:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 376E93858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=osandov.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=osandov.com Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68a42d06d02so227994b3a.0 for ; Thu, 24 Aug 2023 12:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20221208.gappssmtp.com; s=20221208; t=1692906020; x=1693510820; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=y/479XJpvaxQJUVUQZQU5MW5CNPGPDiLsa/u1KrxMXk=; b=QaQE6DGkVfwhICnYQa1pTvLnfpF5MeNgKGJ4yaGPgUipyzDsbhxhl+zxl9JSPSBbig kUmvTNxwzeijVl3OcPtrUyhKzqlgOSsG336fOgKcW4++BnIP2sC9X9DQayjcJj6zZh46 ebUNUpVPEt4hUs+94OMF5cXhBBpyc1nFjKDbbC3F+6dV6HIVAdA6/N+c2L6Hv+Qfcv9R vYZr+KHtXNyrzYVjLpKqo7dxm2DklZCju9BHb8UnTFdS48uuNERABkdDX15cC+u4gnUs LmKXX3t4fNoFKkA3nEiN1kXBMynhUgTYDJUHkO08wxjOo4SRG5f/B3kedR/2qyg7N/43 w1hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692906020; x=1693510820; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=y/479XJpvaxQJUVUQZQU5MW5CNPGPDiLsa/u1KrxMXk=; b=JfegVtz4c7BTxG8381OFyPv6oQcfOnliniJRltNRXIxDRLT9ZRK6r/psaNP+kW5+yz o42vDkB+LY9rkogCHL4W2jH/NpdsLsAzhIb8oLhIsunfshVaVm5UKlVzhdbr3WMrVC7K Och6AHZ4mxqruNbi1/s1N89NFUFNWm5JiKfVv13/fAYR8y+phAZUIGvvj6HGpsUdHJl2 uv1hbwtEEFy2ldpxT4NFed3lQc6x/9t5k9rKNgbcExK1WVFn4MHqvZzZmgO9UmwNC6x7 ToWsOOKKdAJ4OMCFpzyQGXCwbm4LhungrEKHlIQMx3dKiWLqdYgnFeeVMziXJK7UNgl6 vGOw== X-Gm-Message-State: AOJu0YzVmGq1VgwmDEXiaghsVk0QUK4rWgqg8ByZKBJtXmk8AIfwCTKu 8TIcJlj6RwUSyeP2hIcyjwP5YIVGxm2kTtKvcCQ= X-Google-Smtp-Source: AGHT+IE25yjYYpuRTWpoxIWxtgkg554pFZ2kWPhSlygWG2V0hMvSsjbazM0gdVIiOJWrv7tYfL2xcg== X-Received: by 2002:a05:6a21:999c:b0:138:2fb8:6c48 with SMTP id ve28-20020a056a21999c00b001382fb86c48mr16280185pzb.8.1692906020168; Thu, 24 Aug 2023 12:40:20 -0700 (PDT) Received: from telecaster ([2601:602:a300:3bc0::2928]) by smtp.gmail.com with ESMTPSA id u4-20020aa78484000000b00660d80087a8sm102428pfn.187.2023.08.24.12.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 12:40:19 -0700 (PDT) Date: Thu, 24 Aug 2023 12:40:19 -0700 From: Omar Sandoval To: Mark Wielaard Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] libelf, readelf, elflint: Add RELR support Message-ID: References: <20230823220211.1942430-1-mark@klomp.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230823220211.1942430-1-mark@klomp.org> X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Aug 24, 2023 at 12:02:11AM +0200, Mark Wielaard wrote: > Handle RELR as defined here: > https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/YT2RrjpMAwAJ > > Introduce new ELF_T_RELR Elf_Type and handle it for SHT_RELR. Check > various properties in elflint. Print RELR relocations in > readelf. Just the entries with -U. Just the addresses with -N. And > addresses pluse symbol/offsets by default. > > * libebl/eblsectiontypename.c (ebl_section_type_name): Add RELR > to knownstype. > * libelf/elf32_updatenull.c (updatenull_wrlock): Handle > sh_entsize for SHT_RELR. > * libelf/gelf.h (Gelf_Relr): New typedef for Elf64_Relr. > * libelf/gelf_fsize.c (__libelf_type_sizes): Add ELF_T_RELR. > * libelf/gelf_xlate.c (__elf_xfctstom): Likewise. > * libelf/gelf_xlate.h: Add RELR as FUNDAMENTAL. > * libelf/libelf.h (Elf_Type): Add ELF_T_RELR. > * libelf/libelfP.h: Define ELF32_FSZ_RELR and ELF64_FSZ_RELR. > * src/elflint.c (check_reloc_shdr): Check she_entsize for > ELF_T_RELR. > (check_relr): New function. > (check_dynamic): Handle DT_RELR. > (special_sections): Add SHT_RELR. > (check_sections): Call check_relr. > * src/readelf.c (print_relocs): Also accept a Dwfl_Module. > (handle_relocs_relr): New function. > (print_dwarf_addr): Make static and declare early. > (process_elf_file): Pass dwflmod to print_relocs. > (handle_dynamic): Handle DT_RELRSZ and DTRELRENT. > > Signed-off-by: Mark Wielaard > --- > libebl/eblsectiontypename.c | 3 +- > libelf/elf32_updatenull.c | 3 + > libelf/gelf.h | 3 + > libelf/gelf_fsize.c | 3 +- > libelf/gelf_xlate.c | 3 +- > libelf/gelf_xlate.h | 1 + > libelf/libelf.h | 1 + > libelf/libelfP.h | 2 + > src/elflint.c | 51 +++++++++++++-- > src/readelf.c | 125 ++++++++++++++++++++++++++++++++++-- > 10 files changed, 184 insertions(+), 11 deletions(-) > > diff --git a/libebl/eblsectiontypename.c b/libebl/eblsectiontypename.c > index 2008b95a..ade25d4a 100644 > --- a/libebl/eblsectiontypename.c > +++ b/libebl/eblsectiontypename.c > @@ -61,7 +61,8 @@ ebl_section_type_name (Ebl *ebl, int section, char *buf, size_t len) > KNOWNSTYPE (FINI_ARRAY), > KNOWNSTYPE (PREINIT_ARRAY), > KNOWNSTYPE (GROUP), > - KNOWNSTYPE (SYMTAB_SHNDX) > + KNOWNSTYPE (SYMTAB_SHNDX), > + KNOWNSTYPE (RELR) > }; > > /* Handle standard names. */ > diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c > index 6c06e5e4..c5d26b00 100644 > --- a/libelf/elf32_updatenull.c > +++ b/libelf/elf32_updatenull.c > @@ -256,6 +256,9 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int *change_bop, size_t shnum) > case SHT_SUNW_syminfo: > sh_entsize = elf_typesize (LIBELFBITS, ELF_T_SYMINFO, 1); > break; > + case SHT_RELR: > + sh_entsize = elf_typesize (LIBELFBITS, ELF_T_RELR, 1); > + break; > default: > break; > } > diff --git a/libelf/gelf.h b/libelf/gelf.h > index 7a3c87aa..f032d7e1 100644 > --- a/libelf/gelf.h > +++ b/libelf/gelf.h > @@ -82,6 +82,9 @@ typedef Elf64_Rel GElf_Rel; > /* Relocation table entry with addend (in section of type SHT_RELA). */ > typedef Elf64_Rela GElf_Rela; > > +/* Relative relocation entry (in section of type SHT_RELR). */ > +typedef Elf64_Relr Gelf_Relr; Should this be GElf_Relr (with an uppercase E in GElf like the other typedefs)?