From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by sourceware.org (Postfix) with ESMTPS id 965BF3858406 for ; Fri, 4 Mar 2022 13:35:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 965BF3858406 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2108.outbound.protection.outlook.com [104.47.18.108]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-27-NGx2euEdNNq7aab8hig08g-1; Fri, 04 Mar 2022 14:35:00 +0100 X-MC-Unique: NGx2euEdNNq7aab8hig08g-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IX1ZfX/znM3rDqCvwrYdg4CeR2PSe0/cZYfhE7GeA7iLcUPCP/3CEgYNj4mdrg7ApxZqWagKO9sCvyeia3XTFPg0s6hQpP79VyLMHcdsqmuuUVotd+dK4+RfKE/E5mpwgOsr9/VxXBkyDtfMISPYKaN/cQAD+sCrd/5EndrgJtyVjbmq40ZOZQ+TnXPFqRXprcLz5HduD7/QiliCcItBCfJUrlApDFJAa1P7JZKZdUjwjlVL6aWX8YEjITV2RuNZ+ANZwjgDa6d4iy4de/IaspQ0AuU3/m7WwLgTZZGX0D3OL+8KbYd/C4Qxyk49thbLkvMb2zxSFeAv8EQngp02SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GClCaewzHH5ygYls8J8Zor3EBw4cOAfJw7YFjQC2zKY=; b=gF4jltwmhg6YZYGgTuwucPw++RGgTNrXZVAuBBIAKjX8VAdENwY6mOVzJkOCqMoYKOiGW/lQ4IjUbwy1kFBrWZ7s31i6JS6LnqwoRnGizDgbTOWMmy3jYcuS624b7xeUFKUQ8kIDx1rYnv/r4s45e0e3dEW3C+FIl1xyglgF5Sh7JdpTK34NejaRTldRHXpEUEiDWRzlk/UdBt65lZmjYxCcWUcLNURxTrvAQ0PCnW0k0vLCisGCc1IEd7GKbarjOpuwlt0/NvFONN2XJZczVa+8kQR79PsAx5EB/7H/PElWPZ4utpCVwVokxvOCD+E/M+Uecn7dRFlCgG7VYkLjuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) by DB9PR04MB9474.eurprd04.prod.outlook.com (2603:10a6:10:368::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.16; Fri, 4 Mar 2022 13:34:59 +0000 Received: from VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65]) by VI1PR04MB5600.eurprd04.prod.outlook.com ([fe80::d479:b728:345c:bd65%6]) with mapi id 15.20.5038.017; Fri, 4 Mar 2022 13:34:59 +0000 Message-ID: <319f39e5-1f17-23ef-e3fa-2169876aa31c@suse.com> Date: Fri, 4 Mar 2022 14:34:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: [PATCH v2 1/3] x86-64/ELF: permit relaxed overflow checking for 32-bit PC-relative relocs Content-Language: en-US To: Binutils References: From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6P195CA0037.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:87::14) To VI1PR04MB5600.eurprd04.prod.outlook.com (2603:10a6:803:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4df6619-9ba0-4a1a-8069-08d9fde3c744 X-MS-TrafficTypeDiagnostic: DB9PR04MB9474:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ECeLfQ3swyA3Dhd2BZFGcLiAcuDLZw4kAZlT3MRzXUVf95fy+8O57om9WCqUvB3QpWKOoTQ6hQiRY3xI4+kvsrJvYe1NvZvm2DuvyqMvLkRHzryxGdnRRvaOppYgqmxJ7t+tuAlCM9ewcED0R1uEv3fSh3FK0lAYTZXxzBgI2zrC5UMxVpw4M7fAm6wRLtSl5i4F3Luw48tfi7Jeh3rbxspGpOALy0t0V8wlP6KIohS+dPbeeI0Jrz3BbyCFjAORocSgOyW7nPFmVszYCn3rlb8E3+SB8Zg1uTFEm6qmHiSafSyk+g5nCgPslwx11ruzsWKtEiegh4QzZKPHDVIQ/6QyAixY3XPsda3OdyhYzY0DKeU4z9AwS/sAdLRRBaryR3aCnvWes5xi2nzyieXHgG3qtk5sqt59muMd221XXmrn6NJGLgXOzu8mI1YmL/kgJqtHkgt+swfSSku4G0AZsexfR/lpFNaN2l12nQ2jrNL/oIw70q7gxNwwcvNUS3NknJq7iPExcb/1E2UrfI3eEr90JW7qofOj4gsO8DP1Z+DipflJk0amJXnKiRBsyY7srZKljEeblZUkh0fI9FlJrSpWPwYYoMDbDDnullJVyWLR8FVlTkC/zMvzQWQQotpUWLiX+xTNRyHHlNskRwZ3+M0RcdyThyy1/gspBHlNd0G3Fj0UnSPL8EkHl5Y0hsgWJk4+7ACvWjDTsGwn/wUfa17bT+HMVFEDq88CAdD0ku+3uPAwFIj7/Ev3YnOeqmt8 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5600.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(31696002)(38100700002)(83380400001)(8936002)(6916009)(66946007)(66556008)(8676002)(31686004)(66476007)(4326008)(36756003)(5660300002)(316002)(2906002)(86362001)(2616005)(186003)(26005)(508600001)(6486002)(6506007)(6512007)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WmM3SmgvZm9ONVlGaFFDTzR1TzkzS3FVQlJQUHFtbGNkS0dNbzN4bjd4Rngz?= =?utf-8?B?Z1FzWmwzcHRVZ0FRTCt1WDA2UGVjamhlM3hNOEFOdzBhSWtCR21RQjk5RXR5?= =?utf-8?B?M1BDTzJ6WTZwdTJwcG1tQnVlZ0hRVWxjbC9EWWdqVkFleEg5VFVqdjZXazc2?= =?utf-8?B?SG1NcWJrNVlGQjVPYzdZWGM1OU5JNzkwOFc4UVhzSGc4eWpldjl0ZVA4eElR?= =?utf-8?B?V1pzMW9WS25hLzVlR3hqSEZPSGpwRTVJNmhSSEdLbkRxcmwxQUY3aDVEV3Jr?= =?utf-8?B?Sm03Z1B1dGNyZmtCYzZtSkJmYnlJRzZBWGZXWEMxdHZRWWJ5SFFOdERXRWRH?= =?utf-8?B?ZC93NUNlZ2FJdklzQlFFQUVWTjRKdlFNYWNleDdEOTlxWlpoMklvck1PQ0VE?= =?utf-8?B?c2JaenRZelFQaWJZeUxFeDFvNVZKdWhBMStUaVkvY3l5TVVKbVlackNvMFhn?= =?utf-8?B?dG9xbTNGejhIK2tsRTlnc0lvMFArVk12Tk9rYWZEazhXQ1BPaUZ4RUFndFZR?= =?utf-8?B?MDlMRFZGSUhzT3dpRkJqTWN3czBYbHdvUzRQL05WeFg4d2JrdHVqQlo3WTJ3?= =?utf-8?B?U3R6cytkc2lEbndzZ21WSE9QdTJBSjlwWXI3dmhFd2ZSSjl3UUhETkpWTVlj?= =?utf-8?B?eXhWTGNDZzd3WjdKb2FNdlVMTDRxRThmWjRZVFRTSzNTYUxFeDE0VVNPLy9t?= =?utf-8?B?SXkxQWFIVTJwMUsvZHV5OGZEQ0krUVFMQS9yYmY3Zkc2RnhpVnhMSzBHazAx?= =?utf-8?B?N1FlUC9GejVmejhML0FtL0gzY1g5ZW8xVnVYVEJVRThOSTJRcTFJeGo1eUZy?= =?utf-8?B?dFJLaW8ya0xJdVBEcENGY3hUb3Z6VHZLK05VamdFaHpkZkxPYnpwdVNGdGUy?= =?utf-8?B?TTlLNlZlM3poZUlVY1l3VjZWNkxyMDFMSTJUdHFlV29kTys2dERaM2ZaS3BX?= =?utf-8?B?QmJOZHp2ZnJmR3pBeTk2WTUxOWxwOG5uaE9tVXF0WWR2eTZxdS90ay9LNk0x?= =?utf-8?B?a0dRUXZXczQ0MjZEcDZpVWNhOU5sdUhBcVovS2djcXYyQlRmUmFWTFNUSURD?= =?utf-8?B?N2tPYkZtTCttT0xJZk1zYkcwc1pQcHhZK2N1OFFIZ3Y0N0NMTkpwOGhwcFFj?= =?utf-8?B?L0c2NjQ5dWpYWldOUHpReDQ2RmJ6MmVXckJNbFhldkduajZXQ1BST0JLQk0r?= =?utf-8?B?S2Zza1pYV00zQzF6MlRkZDN4b0ZndTRORlJQTmp4R3pWS0d4KzFpZjFlY1Y4?= =?utf-8?B?N095a3dUNXc4UmdlZDhoU3pCbDdCbkVMb1B6KzRiUlUvQTF5b01JVnkva1hY?= =?utf-8?B?aTV5clZQOHNpK1JBV014ak15NEw0QXlKZStSeU56R3hQenQ0OFN0VUJxRGZp?= =?utf-8?B?c1NJQ3VZOW5vVEJueWEyVWQ2ZkJPZ0Rka1h4Q1JzRkQ5N21XTFZMeFJIV0RZ?= =?utf-8?B?YjJvQ2pWb01sQUYrTVdVLzlBSUtzdGNWaW9YSFZmTHllTS84QTBYTzducVlW?= =?utf-8?B?MTlidkpBYjMwdnN2NThDV2VyK1ZYOTlBK2orMVRHcGM2OE94TExmQnhlNlRG?= =?utf-8?B?d2RBbTkvUWZtenByNFdZTVZZcDF0Y3ZqV3QranYvVW1iUUs1UTJjMFhuZ0VP?= =?utf-8?B?WGdnNDlxUk9QQmdrajdIYWx0NW50ajFjQm8yRFdlaDdKcnpPams4RzRGbEFk?= =?utf-8?B?ZEFxRDdKckJDcGIxL3pibWdsOEE0aTZqSFVlU1QyWnRLckt3SkhTa3lSbnh4?= =?utf-8?B?Y3V4TDVmbzQ0MWpRZytIRWxGc01sNnJCY2ZBT2MvemtrTEZSQzdCODdRbTdW?= =?utf-8?B?bGdEMDB4b2szR3JpMUFjd3UyeG9aTFNzMnpXMythWCtVWjd1MHJOY2NVZm9I?= =?utf-8?B?bWpXT2RpL0hiOGpET1JPYyswcW1oUCtwZDZrRWYzUXRlUWh6TzNJS0FqcFE3?= =?utf-8?B?MXF1VW5NZ1VWdjU5YWlDL1hIYU55c01iUnFETVRwbjlvUHdRbnB1anUyamxv?= =?utf-8?B?Y0dhRTR0RU9PbEdEZ0srMFJyc1hRdXZHNzhza2JPbEx5bGN6c2tNRjVjdWlS?= =?utf-8?B?a3NBQXFjcFNPbzhaQjI3N0JsQ25pdVQvK0RrUkFEMmY4UVc2a3ptZGRKZHVS?= =?utf-8?B?ck9VVUxPZnVLWnBpNzloc3FlTXVCWElUU1hvQzI4WXY5QzVVSFRDTStmQkhS?= =?utf-8?Q?+Zx3WxOx90oXN8l5IaQXTiE=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4df6619-9ba0-4a1a-8069-08d9fde3c744 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5600.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Mar 2022 13:34:59.3913 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oFKBXH4BNoN7gBSppqopC0AeM2Q5KMPcygJ4xzg0XlOBsZ+N3T12Sig8mkmO5WmJHKIndg4c1WsOv0Zd3e0qGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9474 X-Spam-Status: No, score=-3032.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 04 Mar 2022 13:35:04 -0000 Right now it is impossible to encode certain valid 32-bit mode constructs; see the respective new test case. Note that there are further 32-bit PC-relative relocations, but I don't think they make a lot of sense to use in mixed-bitness code, so they're not having overrides put in place. Putting in place a new testcase, I'd like to note that the two existing ones (pcrel16 and pcrel16abs) appear to be pretty pointless: They don't expect any error despite supposedly checking for overflow, and in fact there can't possibly be any error for the - former since gas doesn't emit any relocation in the first place there, - latter because the way the relocation gets expressed by gas doesn't allow the linker to notice the overflow; it should be detected by gas if at all, but see above (an error would be reported here for x86-64 afaict, but this test doesn't get re-used there). --- TBD: I didn't put thoughts yet into also making this work when linking ELF to PE. Note that I'm not sure at all whether this propagation of the struct elf_linker_x86_params pointer is actually acceptable. But this is the 5th or 6th try I made, with all others having been worse or not even working out. Hence I'd need pretty detailed guidance on how else the information could be made available. --- v2: Re-base and split. --- a/bfd/elf-linker-x86.h +++ b/bfd/elf-linker-x86.h @@ -28,6 +28,13 @@ enum elf_x86_prop_report prop_report_shstk = 1 << 3 /* Report missing SHSTK property. */ }; +/* Control of PC32 (on 64-bit) overflow check strictness. */ +enum elf_x86_pcrel_relocs +{ + pcrel_relocs_default, + pcrel_relocs_lax, +}; + /* Used to pass x86-specific linker options from ld to bfd. */ struct elf_linker_x86_params { @@ -64,6 +71,9 @@ struct elf_linker_x86_params /* Report relative relocations. */ unsigned int report_relative_reloc : 1; + /* Strictness of PC32 (on 64-bit) overflow checks. */ + enum elf_x86_pcrel_relocs pcrel_relocs; + /* X86-64 ISA level needed. */ unsigned int isa_level; --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -192,6 +192,15 @@ static reloc_howto_type x86_64_elf_howto false) }; +static reloc_howto_type x86_64_howto_pc32_lax = + HOWTO(R_X86_64_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_X86_64_PC32", false, 0, 0xffffffff, true); + +static reloc_howto_type x86_64_howto_pc32_bnd_lax = + HOWTO(R_X86_64_PC32_BND, 0, 2, 32, true, 0, complain_overflow_bitfield, + bfd_elf_generic_reloc, "R_X86_64_PC32_BND", false, 0, 0xffffffff, + true); + /* Map BFD relocs to the x86_64 elf relocs. */ struct elf_reloc_map { @@ -248,6 +257,30 @@ static const struct elf_reloc_map x86_64 }; static reloc_howto_type * +elf_x86_64_reloc_override (const bfd *abfd, reloc_howto_type *howto) +{ + const struct elf_linker_x86_params *params = elf_x86_tdata (abfd)->params; + + switch (howto->type) + { + default: + break; + + case R_X86_64_PC32: + if (params == NULL || params->pcrel_relocs != pcrel_relocs_lax) + break; + return &x86_64_howto_pc32_lax; + + case R_X86_64_PC32_BND: + if (params == NULL || params->pcrel_relocs != pcrel_relocs_lax) + break; + return &x86_64_howto_pc32_bnd_lax; + } + + return howto; +} + +static reloc_howto_type * elf_x86_64_rtype_to_howto (bfd *abfd, unsigned r_type) { unsigned i; @@ -275,7 +308,7 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un else i = r_type - (unsigned int) R_X86_64_vt_offset; BFD_ASSERT (x86_64_elf_howto_table[i].type == r_type); - return &x86_64_elf_howto_table[i]; + return elf_x86_64_reloc_override (abfd, &x86_64_elf_howto_table[i]); } /* Given a BFD reloc type, return a HOWTO structure. */ @@ -313,7 +346,7 @@ elf_x86_64_reloc_name_lookup (bfd *abfd, for (i = 0; i < ARRAY_SIZE (x86_64_elf_howto_table); i++) if (x86_64_elf_howto_table[i].name != NULL && strcasecmp (x86_64_elf_howto_table[i].name, r_name) == 0) - return &x86_64_elf_howto_table[i]; + return elf_x86_64_reloc_override (abfd, &x86_64_elf_howto_table[i]); return NULL; } @@ -1846,6 +1879,9 @@ elf_x86_64_scan_relocs (bfd *abfd, struc BFD_ASSERT (is_x86_elf (abfd, htab)); + /* Make command line controlled settings accessible from the object. */ + elf_x86_tdata (abfd)->params = htab->params; + /* Get the section contents. */ if (elf_section_data (sec)->this_hdr.contents != NULL) contents = elf_section_data (sec)->this_hdr.contents; --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -702,6 +702,9 @@ struct elf_x86_obj_tdata /* R_*_RELATIVE relocation in GOT for this local symbol has been processed. */ char *relative_reloc_done; + + /* Container holding command line controlled linker settings. */ + const struct elf_linker_x86_params *params; }; enum elf_x86_plt_type --- /dev/null +++ b/gas/testsuite/gas/i386/code32.d @@ -0,0 +1,3 @@ +#name: x86-64 code32 +#as: -mx86-used-note=no --generate-missing-build-notes=no +#readelf: -n --- /dev/null +++ b/gas/testsuite/gas/i386/code32.s @@ -0,0 +1,11 @@ + .code32 + .text + .section .text.0, "ax", @progbits + .type func0, @function +func0: + call func1 + ret + .section .text.1, "ax", @progbits + .type func1, @function +func1: + jmp func0 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -1331,6 +1331,7 @@ if [gas_64_check] then { run_dump_test "x86-64-property-8" run_dump_test "x86-64-property-9" run_dump_test "x86-64-property-14" + run_dump_test "code32" if {[istarget "*-*-linux*"]} then { run_dump_test "x86-64-align-branch-3" --- a/ld/emulparams/elf32_x86_64.sh +++ b/ld/emulparams/elf32_x86_64.sh @@ -2,6 +2,7 @@ source_sh ${srcdir}/emulparams/plt_unwin source_sh ${srcdir}/emulparams/extern_protected_data.sh source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh source_sh ${srcdir}/emulparams/reloc_overflow.sh +source_sh ${srcdir}/emulparams/pcrel-relocs.sh source_sh ${srcdir}/emulparams/call_nop.sh source_sh ${srcdir}/emulparams/cet.sh source_sh ${srcdir}/emulparams/x86-report-relative.sh --- a/ld/emulparams/elf_x86_64.sh +++ b/ld/emulparams/elf_x86_64.sh @@ -2,6 +2,7 @@ source_sh ${srcdir}/emulparams/plt_unwin source_sh ${srcdir}/emulparams/extern_protected_data.sh source_sh ${srcdir}/emulparams/dynamic_undefined_weak.sh source_sh ${srcdir}/emulparams/reloc_overflow.sh +source_sh ${srcdir}/emulparams/pcrel-relocs.sh source_sh ${srcdir}/emulparams/call_nop.sh source_sh ${srcdir}/emulparams/cet.sh source_sh ${srcdir}/emulparams/x86-report-relative.sh --- /dev/null +++ b/ld/emulparams/pcrel-relocs.sh @@ -0,0 +1,11 @@ +PARSE_AND_LIST_OPTIONS_STRICT_PCREL_RELOCS=' + fprintf (file, _("\ + -z lax-pcrel-relocs Lax PC-relative relocation overflow checks\n")); +' +PARSE_AND_LIST_ARGS_CASE_Z_STRICT_PCREL_RELOCS=' + else if (strcmp (optarg, "lax-pcrel-relocs") == 0) + params.pcrel_relocs = pcrel_relocs_lax; +' + +PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_STRICT_PCREL_RELOCS" +PARSE_AND_LIST_ARGS_CASE_Z="$PARSE_AND_LIST_ARGS_CASE_Z $PARSE_AND_LIST_ARGS_CASE_Z_STRICT_PCREL_RELOCS" --- a/ld/ld.texi +++ b/ld/ld.texi @@ -1372,6 +1372,12 @@ missing properties in input files. @opt the linker issue an error for missing properties in input files. Supported for Linux/x86_64. +@item lax-pcrel-relocs +Relax relocation overflow checks for certain 32-bit PC-relative relocations +which, when used by 32-bit code inside a 64-bit object, may require a +larger range of values to be considered valid. +Supported for x86-64 ELF targets. + @item lazy When generating an executable or shared library, mark it to tell the dynamic linker to defer function call resolution to the point when --- /dev/null +++ b/ld/testsuite/ld-x86-64/code32.d @@ -0,0 +1,19 @@ +#name: x86-64 R_X86_64_PC32 reloc in 32-bit mode +#source: ${srcdir}/../../../gas/testsuite/gas/i386/code32.s +#as: --64 --generate-missing-build-notes=no +#ld: -T code32.t -z lax-pcrel-relocs +#objdump: -dw -Mi386 + +.*: +file format .* + +Disassembly of section .text.0: + +0+10+ : + +[a-f0-9]+: e8 fb ff ff 8f call a0000000 + +[a-f0-9]+: c3 ret * + +Disassembly of section .text.1: + +0+a0+ : + +[a-f0-9]+: e9 fb ff ff 6f jmp 10000000 +#pass --- /dev/null +++ b/ld/testsuite/ld-x86-64/code32.t @@ -0,0 +1,7 @@ +OUTPUT_FORMAT("elf64-x86-64") +OUTPUT_ARCH("i386:x86-64") +SECTIONS +{ + .text.0 0x10000000 : { *(.text.0) } + .text.1 0xa0000000 : { *(.text.1) } +} --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -501,6 +501,7 @@ run_dump_test "property-x86-isa3-x32" run_dump_test "property-x86-isa4" run_dump_test "property-x86-isa4-x32" run_dump_test "code16" +run_dump_test "code32" run_dump_test "pr27491-1a" run_dump_test "pr27491-1b" run_dump_test "pr27491-1c"