From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id D29213850858 for ; Mon, 27 Jun 2022 03:25:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D29213850858 Received: by mail-pj1-x102d.google.com with SMTP id w19-20020a17090a8a1300b001ec79064d8dso11033772pjn.2 for ; Sun, 26 Jun 2022 20:25:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=UUBFpyel2rhZ9nZttRDGO4pmOSZa1OxLrAZkbXxeYxw=; b=EdbPdbeTzWCBrgXMEMxYHOGIeYSwfUsifQUTVvg4kCeVydrvQets0/PcfhAQh0dv05 3iqakPSeEYZpbquhIxajBCTWUWFEjTkGwFQbDWKWdu0CiEzN5X2RHZCTNf/jMpECjPuN MxU6jBVj095yH0hQj7zmFPXBdZlh45/xqo+wXl7cPGdIXUJTPlp8TUjhslQ9khLzHT4o U0Qrww+25bE0HxI/rQp5EnoPsA3cU/d1L7e3pdUsa5oLQgrpncvDEATX/qS2dMT1NMU4 g/rcUrx0W/QPg+H3T0hNYfhfRxyfoSanksvXOVhJeKx5zvXwBHgBf/MKCOLkUa5/EJb6 +c0A== X-Gm-Message-State: AJIora9QPjI0IJZwb928cItsJmRaZabLPxehF4anS65yRpBBhBARiwiy jd6NJXuGGg+97MrjCTH65cDqBjsGTLc= X-Google-Smtp-Source: AGRyM1u/DXfymxcJ8733EBt2zPSUXOc7TP7joWcG6Zq0cLo8eyyKvcsppEmtnCJoYMOhiRmMK6bl5Q== X-Received: by 2002:a17:90a:4d82:b0:1ec:9777:cb91 with SMTP id m2-20020a17090a4d8200b001ec9777cb91mr18576541pjh.81.1656300314480; Sun, 26 Jun 2022 20:25:14 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:83d:f363:f9df:f154]) by smtp.gmail.com with ESMTPSA id b7-20020a62cf07000000b0051835ccc008sm5908110pfg.115.2022.06.26.20.25.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 20:25:13 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 590CF1140AE7; Mon, 27 Jun 2022 12:55:11 +0930 (ACST) Date: Mon, 27 Jun 2022 12:55:11 +0930 From: Alan Modra To: binutils@sourceware.org Subject: PowerPC64 .branch_lt address Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3036.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2022 03:25:17 -0000 .branch_lt is really an extension of .plt, as is .iplt. We'd like all of the PLT sections to be fixed relative to .TOC. after stub sizing, because changes in offset to PLT entries might mean a change in stub sizes. When -z relro, the relro layout does this by laying out sections from the end of the relro segment. So for example, a change in .eh_frame (which happens after stub sizing) will keep the same GOT to PLT offset when -z relro. Not so when -z norelro, because then the usual forward layout of section is done and .got is more aligned than .branch_lt. * emulparams/elf64ppc.sh: Set .branch_lt address fixed relative to .got. * testsuite/ld-powerpc/elfv2exe.d: Adjust to suit. diff --git a/ld/emulparams/elf64ppc.sh b/ld/emulparams/elf64ppc.sh index a18393b7202..59132fa06fa 100644 --- a/ld/emulparams/elf64ppc.sh +++ b/ld/emulparams/elf64ppc.sh @@ -37,7 +37,7 @@ OTHER_GOT_RELOC_SECTIONS=" OTHER_RELRO_SECTIONS_2=" .opd ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { KEEP (*(.opd)) } .toc1 ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.toc1) } - .branch_lt ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.branch_lt) }" + .branch_lt ${RELOCATING-0}${RELOCATING+(SIZEOF(.got) != 0 ? . + 255 - (255 & (. - 1 + ALIGN(SIZEOF(.branch_lt),8)${RELRO_NOW+ + ALIGN(SIZEOF(.plt),8) + ALIGN(SIZEOF(.iplt),8)})) : ALIGN(8))} : { *(.branch_lt) }" INITIAL_READWRITE_SECTIONS=" .toc ${RELOCATING-0} :${RELOCATING+ ALIGN(8)} { *(.toc) }" # Put .got before .data diff --git a/ld/testsuite/ld-powerpc/elfv2exe.d b/ld/testsuite/ld-powerpc/elfv2exe.d index 0ccfcbf345a..586264d449b 100644 --- a/ld/testsuite/ld-powerpc/elfv2exe.d +++ b/ld/testsuite/ld-powerpc/elfv2exe.d @@ -9,13 +9,13 @@ Disassembly of section \.text: 0+100000c0 <.*\.plt_branch\.f4>: .*: (3d 82 ff ff|ff ff 82 3d) addis r12,r2,-1 -.*: (e9 8c 7f 58|58 7f 8c e9) ld r12,32600\(r12\) +.*: (e9 8c 7f f0|f0 7f 8c e9) ld r12,32752\(r12\) .*: (7d 89 03 a6|a6 03 89 7d) mtctr r12 .*: (4e 80 04 20|20 04 80 4e) bctr 0+100000d0 <.*\.plt_branch\.f2>: .*: (3d 82 ff ff|ff ff 82 3d) addis r12,r2,-1 -.*: (e9 8c 7f 60|60 7f 8c e9) ld r12,32608\(r12\) +.*: (e9 8c 7f f8|f8 7f 8c e9) ld r12,32760\(r12\) .*: (7d 89 03 a6|a6 03 89 7d) mtctr r12 .*: (4e 80 04 20|20 04 80 4e) bctr -- Alan Modra Australia Development Lab, IBM