From patchwork Tue Aug 2 14:59:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 56504 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4183B384B0E7 for ; Tue, 2 Aug 2022 15:01:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4183B384B0E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1659452462; bh=OeozzfJDh+SCf06jxYxfSYZYrthd2tAY1O59Nt4+oWU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=vIZX+9so+QJzOwlYuoO82tOJSbNaAKo4CDlrKJmQpVVUBGFR4lzRJykzvhGfjxrD6 8gt7lfKw9LfGzqzZi4YRRUkgJ1KLr7SKlB3sSbP7oRcAMOO7ogK86OZ8tk5zwf3jBq XMBWqf7xX+QC5Ubcf3+CAWVX/rwfReTbhM5i16HY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-vk1-xa29.google.com (mail-vk1-xa29.google.com [IPv6:2607:f8b0:4864:20::a29]) by sourceware.org (Postfix) with ESMTPS id 657773851AA8 for ; Tue, 2 Aug 2022 14:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 657773851AA8 Received: by mail-vk1-xa29.google.com with SMTP id q14so5733845vke.9 for ; Tue, 02 Aug 2022 07:59:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OeozzfJDh+SCf06jxYxfSYZYrthd2tAY1O59Nt4+oWU=; b=y0/AHpBtkFGIc2kNDAzhD5GGyqwffR6d92qcVfVuDvEzQvEsSr6el8DVSKRpO+IpB6 EujQRx00x6pf4dAzLh1yOTeyTFkVaDVWeiERnWqxDt1l5M2z2x5HJlgoBGTRezOkvFQ0 J8NdX16RdX3o1rkg4xKFdbNQ989WX1URZIoT5Aipuo8JEBCGK/b5MaHb5qoGsXTtwxnH mA9DNdh/7in1SAqtVG0M2w6k8CdVZAs8uF9vgr8bRNbcX3ak77deVK+DGsvgfQDvC1KQ /Er5DaoKXgg5cLHShy+QkLVQ9rl0j7QRnEcLoYALr+43WE/12vhONENe6+cAy5J9020l Lp2g== X-Gm-Message-State: AJIora8zC5MvlC/bmMyyj3lceqZK721FavyQZ2mj5diWlzG7f233p2X/ 8bklZvmbDFCtgdB6M8ioO8o/PPir0lWhTA== X-Google-Smtp-Source: AGRyM1syL7qvQ1PQRL4Xh11SwcBEOttn7Jj5o1XmF/2KNQ1lmyHnS2GWpIs33nwjgxGrhHps53mSUQ== X-Received: by 2002:a1f:dac3:0:b0:377:8cb:4544 with SMTP id r186-20020a1fdac3000000b0037708cb4544mr7326149vkg.7.1659452356348; Tue, 02 Aug 2022 07:59:16 -0700 (PDT) Received: from mandiga.. ([2804:431:c7cb:1e34:2331:a60b:db1e:6436]) by smtp.gmail.com with ESMTPSA id v145-20020a1f2f97000000b003762e090ed8sm8000982vkv.49.2022.08.02.07.59.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 07:59:16 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 5/5] i386: Remove RELA support Date: Tue, 2 Aug 2022 11:59:05 -0300 Message-Id: <20220802145905.2789733-6-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220802145905.2789733-1-adhemerval.zanella@linaro.org> References: <20220802145905.2789733-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Now that prelink is not support, there is no need to keep supporting rela for non bootstrap. --- sysdeps/i386/dl-machine-rel.h | 7 +- sysdeps/i386/dl-machine.h | 191 ---------------------------------- 2 files changed, 1 insertion(+), 197 deletions(-) diff --git a/sysdeps/i386/dl-machine-rel.h b/sysdeps/i386/dl-machine-rel.h index b98273aead..9dfaf718f2 100644 --- a/sysdeps/i386/dl-machine-rel.h +++ b/sysdeps/i386/dl-machine-rel.h @@ -19,13 +19,8 @@ #ifndef _DL_MACHINE_REL_H #define _DL_MACHINE_REL_H -/* The i386 never uses Elf32_Rela relocations for the dynamic linker. - Prelinked libraries may use Elf32_Rela though. */ -#define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP +#define ELF_MACHINE_NO_RELA 1 #define ELF_MACHINE_NO_REL 0 - -/* The i386 never uses Elf32_Rela relocations for the dynamic linker. - Prelinked libraries may use Elf32_Rela though. */ #define ELF_MACHINE_PLT_REL 1 #define PLTREL ElfW(Rel) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 56a189fda2..64aad6e787 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -437,153 +437,6 @@ and creates an unsatisfiable circular dependency.\n", } } -# ifndef RTLD_BOOTSTRAP -static inline void -__attribute__ ((always_inline)) -elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[], - const Elf32_Rela *reloc, const Elf32_Sym *sym, - const struct r_found_version *version, - void *const reloc_addr_arg, int skip_ifunc) -{ - Elf32_Addr *const reloc_addr = reloc_addr_arg; - const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - - if (ELF32_R_TYPE (reloc->r_info) == R_386_RELATIVE) - *reloc_addr = map->l_addr + reloc->r_addend; - else if (r_type != R_386_NONE) - { - const Elf32_Sym *const refsym = sym; - struct link_map *sym_map = RESOLVE_MAP (map, scope, &sym, version, - r_type); - Elf32_Addr value = SYMBOL_ADDRESS (sym_map, sym, true); - - if (sym != NULL - && __glibc_likely (sym->st_shndx != SHN_UNDEF) - && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC) - && __glibc_likely (!skip_ifunc)) - value = ((Elf32_Addr (*) (void)) value) (); - - switch (ELF32_R_TYPE (reloc->r_info)) - { - case R_386_SIZE32: - /* Set to symbol size plus addend. */ - value = sym->st_size; - /* Fall through. */ - case R_386_GLOB_DAT: - case R_386_JMP_SLOT: - case R_386_32: - *reloc_addr = value + reloc->r_addend; - break; - /* Not needed for dl-conflict.c. */ - case R_386_PC32: - *reloc_addr = (value + reloc->r_addend - (Elf32_Addr) reloc_addr); - break; - - case R_386_TLS_DTPMOD32: - /* Get the information from the link map returned by the - resolv function. */ - if (sym_map != NULL) - *reloc_addr = sym_map->l_tls_modid; - break; - case R_386_TLS_DTPOFF32: - /* During relocation all TLS symbols are defined and used. - Therefore the offset is already correct. */ - *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend; - break; - case R_386_TLS_DESC: - { - struct tlsdesc volatile *td = - (struct tlsdesc volatile *)reloc_addr; - -# ifndef RTLD_BOOTSTRAP - if (!sym) - { - td->arg = (void*)reloc->r_addend; - td->entry = _dl_tlsdesc_undefweak; - } - else -# endif - { -# ifndef RTLD_BOOTSTRAP -# ifndef SHARED - CHECK_STATIC_TLS (map, sym_map); -# else - if (!TRY_STATIC_TLS (map, sym_map)) - { - td->arg = _dl_make_tlsdesc_dynamic - (sym_map, sym->st_value + reloc->r_addend); - td->entry = _dl_tlsdesc_dynamic; - } - else -# endif -# endif - { - td->arg = (void*)(sym->st_value - sym_map->l_tls_offset - + reloc->r_addend); - td->entry = _dl_tlsdesc_return; - } - } - } - break; - case R_386_TLS_TPOFF32: - /* The offset is positive, backward from the thread pointer. */ - /* We know the offset of object the symbol is contained in. - It is a positive value which will be subtracted from the - thread pointer. To get the variable position in the TLS - block we subtract the offset from that of the TLS block. */ - if (sym != NULL) - { - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr = sym_map->l_tls_offset - sym->st_value - + reloc->r_addend; - } - break; - case R_386_TLS_TPOFF: - /* The offset is negative, forward from the thread pointer. */ - /* We know the offset of object the symbol is contained in. - It is a negative value which will be added to the - thread pointer. */ - if (sym != NULL) - { - CHECK_STATIC_TLS (map, sym_map); - *reloc_addr = sym->st_value - sym_map->l_tls_offset - + reloc->r_addend; - } - break; - case R_386_COPY: - if (sym == NULL) - /* This can happen in trace mode if an object could not be - found. */ - break; - if (__glibc_unlikely (sym->st_size > refsym->st_size) - || (__glibc_unlikely (sym->st_size < refsym->st_size) - && GLRO(dl_verbose))) - { - const char *strtab; - - strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]); - _dl_error_printf ("\ -%s: Symbol `%s' has different size in shared object, consider re-linking\n", - RTLD_PROGNAME, strtab + refsym->st_name); - } - memcpy (reloc_addr_arg, (void *) value, - MIN (sym->st_size, refsym->st_size)); - break; - case R_386_IRELATIVE: - value = map->l_addr + reloc->r_addend; - if (__glibc_likely (!skip_ifunc)) - value = ((Elf32_Addr (*) (void)) value) (); - *reloc_addr = value; - break; - default: - /* We add these checks in the version to relocate ld.so only - if we are still debugging. */ - _dl_reloc_bad_type (map, r_type, 0); - break; - } - } -} -# endif /* !RTLD_BOOTSTRAP */ static inline void __attribute ((always_inline)) @@ -664,48 +517,4 @@ elf_machine_lazy_rel (struct link_map *map, struct r_scope_elem *scope[], _dl_reloc_bad_type (map, r_type, 1); } -# ifndef RTLD_BOOTSTRAP - -static inline void -__attribute__ ((always_inline)) -elf_machine_lazy_rela (struct link_map *map, struct r_scope_elem *scope[], - Elf32_Addr l_addr, const Elf32_Rela *reloc, - int skip_ifunc) -{ - Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset); - const unsigned int r_type = ELF32_R_TYPE (reloc->r_info); - if (__glibc_likely (r_type == R_386_JMP_SLOT)) - ; - else if (__glibc_likely (r_type == R_386_TLS_DESC)) - { - const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info); - const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]); - const ElfW (Sym) *sym = &symtab[symndx]; - const struct r_found_version *version = NULL; - - if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL) - { - const ElfW (Half) *vernum = - (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]); - version = &map->l_versions[vernum[symndx] & 0x7fff]; - } - - /* Always initialize TLS descriptors completely at load time, in - case static TLS is allocated for it that requires locking. */ - elf_machine_rela (map, scope, reloc, sym, version, reloc_addr, - skip_ifunc); - } - else if (__glibc_unlikely (r_type == R_386_IRELATIVE)) - { - Elf32_Addr value = map->l_addr + reloc->r_addend; - if (__glibc_likely (!skip_ifunc)) - value = ((Elf32_Addr (*) (void)) value) (); - *reloc_addr = value; - } - else - _dl_reloc_bad_type (map, r_type, 1); -} - -# endif /* !RTLD_BOOTSTRAP */ - #endif /* RESOLVE_MAP */