From patchwork Fri Oct 4 07:31:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 98356 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 85D98384514B for ; Fri, 4 Oct 2024 07:31:34 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 6A1B3385DDDA for ; Fri, 4 Oct 2024 07:31:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A1B3385DDDA Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A1B3385DDDA Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::533 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728027068; cv=none; b=eVbmx4WjqBwHSe7Mi8L7KFPBInjdjfCCVC9VBxLKK0QS+QW2JNYqfqdL0Nd+vGMAQpsv0uqIYG4Xb7c11W4oU37H9xLxhMIYp2n27AlyQgTELdmVt50TmOVXOn1oueER2RqB+L8qUVu0XSdR0CDqeJsPUsf+CQPMsUMF56p0skE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728027068; c=relaxed/simple; bh=9scbLM4n87QNqskJA0KljalLWJ+IT9FIFWBzDskC9ZU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=DayuZF3/mtwbKoNvAcPdng4esg3mchpp3k1lGBrFxJuDv2FZYMfT3yIwek8Dnl4+lB3XnWzHRWA9kW6deMm3N3Gt2rJFgkKJQlMADfxhzzTN06WRxVl3vPAbEYNRtoG0IdDjY1c1o4jTF+Q9SL/WOvG7uC4BRztc29djc8I4Qqk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5c88b5c375fso2016163a12.3 for ; Fri, 04 Oct 2024 00:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728027064; x=1728631864; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CDEOGYVHB9pcdPRQROt6Eq7ePcoyQ2ii6xn0d1K9dNs=; b=QqBGHY0wvM/FysRpok/uXMNy8gDotGi68nOmrF1tWrEKopqhEI6l8gSDN/H8T9Argv LT98v1+mvrkwbIgITTFplDuY0E86K8xOynBPa9j/59eTz+fsf2GbltwkAoqRCbccA8Uh RRlLmmMG6ytUW0vfjmQUQ9BSzQVkvJv9VZJnsSSMbarA8JJHO9uh3vZBgrBo4tuVay5l ABrFjUghrv8bOeyg/HLEI4p/riL54vXVPumXCMsbBKF4IS02ek/4Mmi82O+i0TUU6+6b 1r2eE2DoDKnKd56mwCFIv7B2SgeCCaSvXOEDByemnaXJ3f2xCaIXDax9zeY36kcW9+ly AVlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728027064; x=1728631864; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CDEOGYVHB9pcdPRQROt6Eq7ePcoyQ2ii6xn0d1K9dNs=; b=vdY84/AzDktPxn3vCMOqo5x/AFCdXWi6tG4bvfxsr6J9MmD16v8SMqnI5DUx04dC3E NJPFM3DnxXqnQNJjEIdfc7lBTN8B4//k/+ywCFqWnxrqmQKTkXIRBSuYpHqq1TPqyxCO BWnSz3r0o8E3oVI3iCIu8zSEd0cFHxvu7TvvTkFyU1ax+QKfYRl4WBMgyNGFyyf8NSJg FGbtr0iFAzCkP5sqGLzffGy7XiUcfmYkW1kBi4tOn9FXeTJlvfDAS6GGEUsdoewPgpKi DuPsvZroNK/TZiSncCOTVsGMo2gYC3Bt8bTb3iXQ1lEJDgNDZwRgPJyR3ThU8jErohZS ghAQ== X-Gm-Message-State: AOJu0YxoLJwoabaOu3PN/A0CGeg+zrOpQmEo3vmNeC9XyFWeESYFZB/H 3X6pMgo3a69vk9ki6uyptn1nSeCPl0kiTm/SxYo4d89rkHoBnCAOC9j7hcsesIQdtBjIORSGzLI = X-Google-Smtp-Source: AGHT+IE/VAVsqDF/l3Pb2b2c69Gpe58n4Us2pz1b3ROGuz6KxsLK3HHpOdaeMWXOhQj3xVRo7nq8sQ== X-Received: by 2002:a05:6402:3514:b0:5c8:84a8:5185 with SMTP id 4fb4d7f45d1cf-5c8d2e11c3bmr984825a12.6.1728027063902; Fri, 04 Oct 2024 00:31:03 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8ca4d7e51sm1551032a12.71.2024.10.04.00.31.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2024 00:31:03 -0700 (PDT) Message-ID: <2883a774-5534-4e0f-9c9d-b5eec3d5d43b@suse.com> Date: Fri, 4 Oct 2024 09:31:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 1/2] bfd/ELF: restrict file alignment for object files From: Jan Beulich To: Binutils References: <15edc241-783f-43e6-9e87-343e8a141c5c@suse.com> Content-Language: en-US Cc: Alan Modra , Nick Clifton , "ramana.radhakrishnan@arm.com" , Richard Earnshaw , Marcus Shawcroft , "H.J. Lu" , Hans-Peter Nilsson , Jim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wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <15edc241-783f-43e6-9e87-343e8a141c5c@suse.com> X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org While for executables properly aligning sections within the file can be quite relevant, the same is of pretty little importance for relocatable object files. Avoid passing "true" into _bfd_elf_assign_file_position_for_section() when dealing with object files, but compensate minimally by applying log_file_align in such cases as a cap to the alignment put in place. --- RFC: Question is whether this minimal alignment shouldn't be applied in all cases, i.e. also when incoming "align" is "true". The Arm64 test being adjusted has an imo misleading name: I first thought I broke something. Only when going back to the commit that introduced it, I found that the test is about the _absence_ of tail padding. Would people mind if I inserted e.g. "no" on the #name line? --- v2: Replace heuristic in _bfd_elf_assign_file_position_for_section(). --- a/bfd/elf.c +++ b/bfd/elf.c @@ -4562,10 +4562,23 @@ align_file_position (file_ptr off, int a file_ptr _bfd_elf_assign_file_position_for_section (Elf_Internal_Shdr *i_shdrp, file_ptr offset, - bool align) + bool align, + unsigned char log_file_align) { - if (align && i_shdrp->sh_addralign > 1) - offset = BFD_ALIGN (offset, i_shdrp->sh_addralign & -i_shdrp->sh_addralign); + if (i_shdrp->sh_addralign > 1) + { + file_ptr salign = i_shdrp->sh_addralign & -i_shdrp->sh_addralign; + + if (align) + offset = BFD_ALIGN (offset, salign); + else if (log_file_align) + { + /* Heuristic: Cap alignment at log_file_align. */ + file_ptr falign = 1u << log_file_align; + + offset = BFD_ALIGN (offset, salign < falign ? salign : falign); + } + } i_shdrp->sh_offset = offset; if (i_shdrp->bfd_section != NULL) i_shdrp->bfd_section->filepos = offset; @@ -4653,18 +4666,18 @@ _bfd_elf_compute_section_file_positions off = elf_next_file_pos (abfd); hdr = & elf_symtab_hdr (abfd); - off = _bfd_elf_assign_file_position_for_section (hdr, off, true); + off = _bfd_elf_assign_file_position_for_section (hdr, off, true, 0); if (elf_symtab_shndx_list (abfd) != NULL) { hdr = & elf_symtab_shndx_list (abfd)->hdr; if (hdr->sh_size != 0) - off = _bfd_elf_assign_file_position_for_section (hdr, off, true); + off = _bfd_elf_assign_file_position_for_section (hdr, off, true, 0); /* FIXME: What about other symtab_shndx sections in the list ? */ } hdr = &elf_tdata (abfd)->strtab_hdr; - off = _bfd_elf_assign_file_position_for_section (hdr, off, true); + off = _bfd_elf_assign_file_position_for_section (hdr, off, true, 0); elf_next_file_pos (abfd) = off; @@ -6538,8 +6551,8 @@ assign_file_positions_for_non_load_secti else align = hdr->sh_addralign & -hdr->sh_addralign; off += vma_page_aligned_bias (hdr->sh_addr, off, align); - off = _bfd_elf_assign_file_position_for_section (hdr, off, - false); + off = _bfd_elf_assign_file_position_for_section (hdr, off, false, + bed->s->log_file_align); } else if (((hdr->sh_type == SHT_REL || hdr->sh_type == SHT_RELA) && hdr->bfd_section == NULL) @@ -6556,7 +6569,7 @@ assign_file_positions_for_non_load_secti || hdr == i_shdrpp[elf_shstrtab_sec (abfd)]) hdr->sh_offset = -1; else - off = _bfd_elf_assign_file_position_for_section (hdr, off, true); + off = _bfd_elf_assign_file_position_for_section (hdr, off, true, 0); } elf_next_file_pos (abfd) = off; @@ -6793,7 +6806,8 @@ assign_file_positions_except_relocs (bfd hdr->sh_offset = -1; } else - off = _bfd_elf_assign_file_position_for_section (hdr, off, true); + off = _bfd_elf_assign_file_position_for_section (hdr, off, false, + 0); } elf_next_file_pos (abfd) = off; @@ -7008,7 +7022,7 @@ _bfd_elf_assign_file_positions_for_non_l Elf_Internal_Shdr **shdrpp, **end_shdrpp; Elf_Internal_Shdr *shdrp; Elf_Internal_Ehdr *i_ehdrp; - const struct elf_backend_data *bed; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); /* Skip non-load sections without section header. */ if ((abfd->flags & BFD_NO_SECTION_HEADER) != 0) @@ -7076,7 +7090,10 @@ _bfd_elf_assign_file_positions_for_non_l sec->contents = NULL; } - off = _bfd_elf_assign_file_position_for_section (shdrp, off, true); + off = _bfd_elf_assign_file_position_for_section (shdrp, off, + (abfd->flags & (EXEC_P | DYNAMIC)) + || bfd_get_format (abfd) == bfd_core, + bed->s->log_file_align); } } @@ -7085,11 +7102,10 @@ _bfd_elf_assign_file_positions_for_non_l _bfd_elf_strtab_finalize (elf_shstrtab (abfd)); shdrp = &elf_tdata (abfd)->shstrtab_hdr; shdrp->sh_size = _bfd_elf_strtab_size (elf_shstrtab (abfd)); - off = _bfd_elf_assign_file_position_for_section (shdrp, off, true); + off = _bfd_elf_assign_file_position_for_section (shdrp, off, true, 0); /* Place the section headers. */ i_ehdrp = elf_elfheader (abfd); - bed = get_elf_backend_data (abfd); off = align_file_position (off, 1 << bed->s->log_file_align); i_ehdrp->e_shoff = off; off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2540,7 +2540,7 @@ extern long _bfd_elf_link_lookup_local_d extern bool _bfd_elf_compute_section_file_positions (bfd *, struct bfd_link_info *); extern file_ptr _bfd_elf_assign_file_position_for_section - (Elf_Internal_Shdr *, file_ptr, bool); + (Elf_Internal_Shdr *, file_ptr, bool, unsigned char); extern bool _bfd_elf_modify_headers (bfd *, struct bfd_link_info *); --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -12914,7 +12914,7 @@ bfd_elf_final_link (bfd *abfd, struct bf { file_ptr off = elf_next_file_pos (abfd); - _bfd_elf_assign_file_position_for_section (symtab_hdr, off, true); + _bfd_elf_assign_file_position_for_section (symtab_hdr, off, true, 0); /* Note that at this point elf_next_file_pos (abfd) is incorrect. We do not yet know the size of the .symtab section. @@ -13358,7 +13358,7 @@ bfd_elf_final_link (bfd *abfd, struct bf symtab_shndx_hdr->sh_size = amt; off = _bfd_elf_assign_file_position_for_section (symtab_shndx_hdr, - off, true); + off, true, 0); if (bfd_seek (abfd, symtab_shndx_hdr->sh_offset, SEEK_SET) != 0 || (bfd_write (flinfo.symshndxbuf, amt, abfd) != amt)) @@ -13382,7 +13382,7 @@ bfd_elf_final_link (bfd *abfd, struct bf symstrtab_hdr->sh_addralign = 1; off = _bfd_elf_assign_file_position_for_section (symstrtab_hdr, - off, true); + off, true, 0); elf_next_file_pos (abfd) = off; if (bfd_seek (abfd, symstrtab_hdr->sh_offset, SEEK_SET) != 0 --- a/binutils/testsuite/binutils-all/i386/compressed-1b.d +++ b/binutils/testsuite/binutils-all/i386/compressed-1b.d @@ -10,9 +10,9 @@ There are 5 section headers, starting at Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 - \[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16 - \[ 2\] .data PROGBITS 00000000 00005b 000000 00 WA 0 0 1 - \[ 3\] .bss NOBITS 00000000 00005b 000000 00 WA 0 0 1 - \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 . 0 0 1 + \[ 1\] .text PROGBITS 00000000 0000.. 00001b 00 AX 0 0 16 + \[ 2\] .data PROGBITS 00000000 0000.. 000000 00 WA 0 0 1 + \[ 3\] .bss NOBITS 00000000 0000.. 000000 00 WA 0 0 1 + \[ 4\] .shstrtab STRTAB 00000000 0000.. 00001c 00 .. 0 0 1 Key to Flags: #... --- a/binutils/testsuite/binutils-all/i386/compressed-1c.d +++ b/binutils/testsuite/binutils-all/i386/compressed-1c.d @@ -10,9 +10,9 @@ There are 5 section headers, starting at Section Headers: \[Nr\] Name Type Addr Off Size ES Flg Lk Inf Al \[ 0\] NULL 00000000 000000 000000 00 0 0 0 - \[ 1\] .text PROGBITS 00000000 000040 00001b 00 AX 0 0 16 - \[ 2\] .data PROGBITS 00000000 00005b 000000 00 WA 0 0 1 - \[ 3\] .bss NOBITS 00000000 00005b 000000 00 WA 0 0 1 - \[ 4\] .shstrtab STRTAB 00000000 [0-9a-f]+ 00001c 00 .* 0 0 1 + \[ 1\] .text PROGBITS 00000000 0000.. 00001b 00 AX 0 0 16 + \[ 2\] .data PROGBITS 00000000 0000.. 000000 00 WA 0 0 1 + \[ 3\] .bss NOBITS 00000000 0000.. 000000 00 WA 0 0 1 + \[ 4\] .shstrtab STRTAB 00000000 0000.. 00001c 00 .. 0 0 1 Key to Flags: #... --- a/binutils/testsuite/binutils-all/readelf.s +++ b/binutils/testsuite/binutils-all/readelf.s @@ -10,7 +10,7 @@ Section Headers: # MIPS targets put .rela.text here. #... +\[ .\] .* +PROGBITS +00000000 0000(3c|40|44|48|50) 0000(04|10) 00 +WA +0 +0 +(.|..) - +\[ .\] .* +NOBITS +00000000 0000(40|44|48|4c|60) 000000 00 +WA +0 +0 +(.|..) + +\[ .\] .* +NOBITS +00000000 0+[0-9a-f]+ 000000 00 +WA +0 +0 +(.|..) # ARM targets put .ARM.attributes here. # MIPS targets put .reginfo, .mdebug, .MIPS.abiflags and .gnu.attributes here. # v850 targets put .call_table_data and .call_table_text here. --- a/gas/testsuite/gas/aarch64/tail_padding.d +++ b/gas/testsuite/gas/aarch64/tail_padding.d @@ -11,10 +11,10 @@ Section Headers: Size EntSize Flags Link Info Align \[ 0\] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 - \[ 1\] \.text PROGBITS 0000000000000000 00000040 + \[ 1\] \.text PROGBITS 0000000000000000 000000.. 0000000000000000 0000000000000000 AX 0 0 1 - \[ 2\] \.data PROGBITS 0000000000000000 00000040 + \[ 2\] \.data PROGBITS 0000000000000000 000000.. 0000000000000008 0000000000000000 WA 0 0 64 - \[ 3\] \.bss NOBITS 0000000000000000 00000080 + \[ 3\] \.bss NOBITS 0000000000000000 000000.. 000000000000000c 0000000000000000 WA 0 0 64 #... --- a/gas/testsuite/gas/arm/ehabi-pacbti-m.d +++ b/gas/testsuite/gas/arm/ehabi-pacbti-m.d @@ -4,7 +4,7 @@ #readelf: -u #target: [is_elf_format] -Unwind section '.ARM.exidx' at offset 0x5c contains 1 entry: +Unwind section '.ARM.exidx' at offset 0x[0-9a-f]+ contains 1 entry: 0x0: @0x0 Compact model index: 1 --- a/gas/testsuite/gas/ia64/group-1.d +++ b/gas/testsuite/gas/ia64/group-1.d @@ -8,15 +8,15 @@ Section Headers: Size EntSize Flags Link Info Align \[ 0\] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 - \[ 1\] \.group GROUP 0000000000000000 00000040 + \[ 1\] \.group GROUP 0000000000000000 [0-9a-f]+ 0000000000000008 0000000000000004 6 6 4 - \[ 2\] \.text PROGBITS 0000000000000000 00000050 + \[ 2\] \.text PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 AX 0 0 16 - \[ 3\] \.data PROGBITS 0000000000000000 00000050 + \[ 3\] \.data PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 WA 0 0 1 - \[ 4\] \.bss NOBITS 0000000000000000 00000050 + \[ 4\] \.bss NOBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 WA 0 0 1 - \[ 5\] \.text PROGBITS 0000000000000000 00000050 + \[ 5\] \.text PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000010 0000000000000000 AXG 0 0 16 \[ 6\] \.symtab SYMTAB 0000000000000000 .* 00000000000000c0 0000000000000018 7 8 8 --- a/gas/testsuite/gas/ia64/group-2.d +++ b/gas/testsuite/gas/ia64/group-2.d @@ -9,19 +9,19 @@ Section Headers: Size EntSize Flags Link Info Align \[ 0\] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 - \[ 1\] \.group GROUP 0000000000000000 00000040 + \[ 1\] \.group GROUP 0000000000000000 [0-9a-f]+ 0000000000000014 0000000000000004 9 5 4 - \[ 2\] \.text PROGBITS 0000000000000000 00000060 + \[ 2\] \.text PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 AX 0 0 16 - \[ 3\] \.data PROGBITS 0000000000000000 00000060 + \[ 3\] \.data PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 WA 0 0 1 - \[ 4\] \.bss NOBITS 0000000000000000 00000060 + \[ 4\] \.bss NOBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 WA 0 0 1 - \[ 5\] \.gnu\.linkonce\.t\.f PROGBITS 0000000000000000 00000060 + \[ 5\] \.gnu\.linkonce\.t\.f PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000000 0000000000000000 AXG 0 0 16 - \[ 6\] \.gnu\.linkonce\.ia6 PROGBITS 0000000000000000 00000060 + \[ 6\] \.gnu\.linkonce\.ia6 PROGBITS 0000000000000000 [0-9a-f]+ 0000000000000010 0000000000000000 AG 0 0 8 - \[ 7\] \.gnu\.linkonce\.ia6 IA_64_UNWIND 0000000000000000 00000070 + \[ 7\] \.gnu\.linkonce\.ia6 IA_64_UNWIND 0000000000000000 [0-9a-f]+ 0000000000000018 0000000000000000 ALG 5 5 8 \[ 8\] \.rela\.gnu\.linkonc RELA 0000000000000000 .* 0000000000000048 0000000000000018 IG 9 7 8 --- a/gas/testsuite/gas/mmix/bspec-2.d +++ b/gas/testsuite/gas/mmix/bspec-2.d @@ -1,11 +1,11 @@ #readelf: -Sr -T -x1 -x4 There are 11 section headers, starting at offset .*: #... - \[ 4\] \.MMIX\.spec_data\.2 PROGBITS 0+ 0+48 + \[ 4\] \.MMIX\.spec_data\.2 PROGBITS 0+ [0-9a-f]+ 0+10 0+ 0 0 8 \[ 5\] \.rela\.MMIX\.spec_d RELA 0+ .* +0+30 0+18 +I +8 +4 +8 - \[ 6\] \.MMIX\.spec_data\.3 PROGBITS 0+ 0+58 + \[ 6\] \.MMIX\.spec_data\.3 PROGBITS 0+ [0-9a-f]+ 0+8 0+ 0 0 8 \[ 7\] \.rela\.MMIX\.spec_d RELA 0+ .* +0+18 +0+18 +I +8 +6 +8 --- a/ld/testsuite/ld-x86-64/pr27590.rd +++ b/ld/testsuite/ld-x86-64/pr27590.rd @@ -1,11 +1,11 @@ #... - \[[ 0-9]+\] .gnu.debuglto_.debug_info PROGBITS +0+ 0+28a 0+42 00 +E 0 +0 1 - \[[ 0-9]+\] .rela.gnu.debuglto_.debug_info RELA +0+ 0+810 0+f0 18 +I 26 17 8 - \[[ 0-9]+\] .gnu.debuglto_.debug_abbrev PROGBITS +0+ 0+2cc 0+26 00 +E 0 +0 1 - \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ 0+2f2 0+2a 00 +E 0 +0 1 - \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ 0+900 0+60 18 +I 26 20 8 - \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ 0+31c 0+10 00 GE 0 +0 1 - \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ 0+960 0+30 18 IG 26 22 8 - \[[ 0-9]+\] .gnu.debuglto_.debug_line PROGBITS +0+ 0+32c 0+8a 00 +E 0 +0 1 - \[[ 0-9]+\] .gnu.debuglto_.debug_str PROGBITS +0+ 0+3b6 0+15c 01 MSE 0 +0 1 + \[[ 0-9]+\] .gnu.debuglto_.debug_info PROGBITS +0+ [0-9a-f]+ 0+42 00 +E 0 +0 1 + \[[ 0-9]+\] .rela.gnu.debuglto_.debug_info RELA +0+ [0-9a-f]+ 0+f0 18 +I 26 17 8 + \[[ 0-9]+\] .gnu.debuglto_.debug_abbrev PROGBITS +0+ [0-9a-f]+ 0+26 00 +E 0 +0 1 + \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ [0-9a-f]+ 0+2a 00 +E 0 +0 1 + \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+60 18 +I 26 20 8 + \[[ 0-9]+\] .gnu.debuglto_.debug_macro PROGBITS +0+ [0-9a-f]+ 0+10 00 GE 0 +0 1 + \[[ 0-9]+\] .rela.gnu.debuglto_.debug_macro RELA +0+ [0-9a-f]+ 0+30 18 IG 26 22 8 + \[[ 0-9]+\] .gnu.debuglto_.debug_line PROGBITS +0+ [0-9a-f]+ 0+8a 00 +E 0 +0 1 + \[[ 0-9]+\] .gnu.debuglto_.debug_str PROGBITS +0+ [0-9a-f]+ 0+15c 01 MSE 0 +0 1 #pass From patchwork Fri Oct 4 07:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 98357 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 44F653846425 for ; Fri, 4 Oct 2024 07:32:30 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id BB0ED385DDFB for ; Fri, 4 Oct 2024 07:32:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB0ED385DDFB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BB0ED385DDFB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728027125; cv=none; b=P+FZIbJjznnrzCgZxJHlbkLtocAUggmHWltOI02/ahgugK+wU1oZL/ZKlZ2zk2LIIqwEqSNGUP97badM5cQmzNjoNwmEYhx6O7hh8GlWVwJzYVtX+7Eo44rkk0kQO6ibHnyeXdJ5H53oZuoI033mPefTaxzS/43L0V+Wl10i2vM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728027125; c=relaxed/simple; bh=9EYurng9B9rLVDbZCQ+xuVOrRlQq17030b7wb6xaoZ0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=vdinJqIk53s819i+jnNW2m/oQQa2NXWaUPotuuKzZYbg9B+y0y5IonJU51ZsTOAiuwwGxig1mblc9fb/tQNmzh8TcWAy+h2v5hI5jJE8mj39eHI4ua2/UPwlQWqEB/9ShEi7YJefRHNh3N+oTO5eGE6o9laLjiHX196Hh2fSAYU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5c88e6926e5so1835460a12.3 for ; Fri, 04 Oct 2024 00:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1728027122; x=1728631922; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2JQH7rG1BD++t9veOgLsQAWRJea/vQNRxBWW1o493sg=; b=CmzhUecRXsUsgcERkQVec36ENjWehtg9/yEDp2pVL5sVQjm0t8hkFLJ4Xtf5q/Midg wtZb+z5UZPEtTVz+TgG1AjQ/tUqGkdvoxxQLM6Gm+wnZA0BRy4/uCEA+fE33/XEN/65A bQq0RaoLhxzOj0iKqTOdQNDA6as24UdovAcSOS9br75QgtW0KwSLyFk9NRg9E7REZ+kG fDiXfWFvuuDcmTep+JNziahy7xqFsP3szjYlzG0wuUAeJN+dBUn+XfHLy3y3j/GS8Xmd NmjK9E3uovqfJyty3lzi74EdXuGonPlSZXYQ2pHl3pRskipyWsKTe5kOqiWPSEThXZnz 55Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728027122; x=1728631922; h=content-transfer-encoding:in-reply-to:autocrypt:cc:content-language :references:to:from:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2JQH7rG1BD++t9veOgLsQAWRJea/vQNRxBWW1o493sg=; b=jEDv20G00k9wddUDYBxkEu5FBqbseIWVyYilRoQcl6IiSJ1P62KW+MT3NcFPsz8k+G X7PMqFOBLk1dtuFa20JQl/YHcFvN9oEycrZCNimCrQitwKA+FDrPEZeTeNOFRFsd5RZn hVFE1LgjHvb1xqwbUPL7hxadUc0Tn4uEu2by/5toqYVNNaoNCPPNVWHW/pj7EcmBkOJE bc6Vdohjq1TQ62J9O18RELnK8p1pl2YYwX23ZHHvqZybUsKtKTffHVK1zVkMr5CQ7Isw N351MmMx/8YvyOvTrKgxNDqYy1Odl+qiKcCm5IrbxywBi+ysJxFWIU/oGpt6YMjvPwry ejMg== X-Gm-Message-State: AOJu0YzMa8PBeUl8G8ObeIDJVyhRxTjo4MQVddmf+ZPaEkk2w+XeOpjM MdXxhlR8JIN7a+AEtNxbzeqRaQ6uAy7c424bSMXlCkFxijUyKS1MokZaiaTMVfQU79pAp/ZgRNY = X-Google-Smtp-Source: AGHT+IGFJ3RsIdd2PBCodJGhTMUFoxj3MKZq+a0yoCiqhyAIMy66pkj39YowlW5szfoNI+/RzsJo9Q== X-Received: by 2002:a05:6402:1d54:b0:5c8:81bd:ac90 with SMTP id 4fb4d7f45d1cf-5c8d2e75d91mr1306782a12.27.1728027122303; Fri, 04 Oct 2024 00:32:02 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c8ca3fce32sm1536445a12.57.2024.10.04.00.32.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Oct 2024 00:32:02 -0700 (PDT) Message-ID: <0d5cc1d7-1a4a-4d19-86a9-fa16e383fa94@suse.com> Date: Fri, 4 Oct 2024 09:32:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 2/2] bfd/ELF: drop align_file_position() From: Jan Beulich To: Binutils References: <15edc241-783f-43e6-9e87-343e8a141c5c@suse.com> Content-Language: en-US Cc: Nick Clifton , Alan Modra Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSR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kkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <15edc241-783f-43e6-9e87-343e8a141c5c@suse.com> X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Switch the sole user to BFD_ALIGN() instead. (It's comment was partly wrong [stale?] anyway, talking of some maximum that was nowhere in sight.) --- v2: New. --- a/bfd/elf.c +++ b/bfd/elf.c @@ -4547,15 +4547,6 @@ elf_map_symbols (bfd *abfd, unsigned int return true; } -/* Align to the maximum file alignment that could be required for any - ELF data structure. */ - -static inline file_ptr -align_file_position (file_ptr off, int align) -{ - return (off + align - 1) & ~(align - 1); -} - /* Assign a file position to a section, optionally aligning to the required section alignment. */ @@ -7106,7 +7097,7 @@ _bfd_elf_assign_file_positions_for_non_l /* Place the section headers. */ i_ehdrp = elf_elfheader (abfd); - off = align_file_position (off, 1 << bed->s->log_file_align); + off = BFD_ALIGN (off, 1u << bed->s->log_file_align); i_ehdrp->e_shoff = off; off += i_ehdrp->e_shnum * i_ehdrp->e_shentsize; elf_next_file_pos (abfd) = off;