From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.67612.1679562309518766821 for ; Thu, 23 Mar 2023 02:05:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jEEvtGOH; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6BA9FB82016 for ; Thu, 23 Mar 2023 09:05:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FF61C433A1 for ; Thu, 23 Mar 2023 09:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679562305; bh=D4CwERGx1GVsFaXqH7x7ehLWIZNRXKeE7Fw2JnRkcUI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jEEvtGOHE0tOITM2Nzxyw5o373KyPhwmqR9PAmuZ8csiY26KlfGKznmupn/NNjnHZ IKi7fPuPvZXb2YBjYQTwuc+CHr/wXnxwy0QD0mLT4r64t/XQATtTkpP9o86yOSZXue sN0JVvrPkvxPWCbZtPLKENqOzLF1EtmVnQ4BWiTQLzwwaHvAW9oMWOvSWV1g/Lr5rX dcpQgYBtbVuUEundIIvXiBH9+LruHoM/ctG2kixh2nTo5bUBqB44pUW0jNIzdmgaYT wmdrIIyP8Ooj2839sPOt24H0CZKSWWFbzGaNUZvycSWyInFn2BrW9yUB/gntKutAa5 +On/bwBSysc1Q== Received: by mail-lf1-f50.google.com with SMTP id c29so9304025lfv.3 for ; Thu, 23 Mar 2023 02:05:05 -0700 (PDT) X-Gm-Message-State: AAQBX9cKws6Fn6LWrurGEXwtAJq9H5yaGd/hvQMrUg12efGqE33FHbjE VJJc8cpsWrhXVf0/EKW5v/jAIAGP2F3amLHUVmM= X-Google-Smtp-Source: AK7set8W/RuCorssQaT9jrXpBxh/xSDosTd1MZc9tU1vJK76SbMWcGQcTjAkCH21Ojz9B70OOL3o5g+Cder2DMwF08Y= X-Received: by 2002:ac2:53a9:0:b0:4ea:12f7:a725 with SMTP id j9-20020ac253a9000000b004ea12f7a725mr2808859lfh.4.1679562303497; Thu, 23 Mar 2023 02:05:03 -0700 (PDT) MIME-Version: 1.0 References: <20230322013040.3322865-1-rebecca@bsdio.com> <20230322013040.3322865-4-rebecca@bsdio.com> <5f85abe6-4a08-0f70-9efc-d671770c1201@bsdio.com> In-Reply-To: <5f85abe6-4a08-0f70-9efc-d671770c1201@bsdio.com> From: "Ard Biesheuvel" Date: Thu, 23 Mar 2023 10:04:52 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/9] BaseTools: Update CLANGDWARF toolchain and remove CLANG35 and CLANG38 To: Rebecca Cran Cc: devel@edk2.groups.io, Michael D Kinney , Liming Gao , Zhiguang Liu , Bob Feng , Yuwei Chen , Andrew Fish , Leif Lindholm , Ard Biesheuvel , Jordan Justen , Gerd Hoffmann Content-Type: text/plain; charset="UTF-8" On Thu, 23 Mar 2023 at 02:30, Rebecca Cran wrote: > > On 3/22/23 5:49 AM, Ard Biesheuvel wrote: > > > > > The reason I added CLANG3x support for ARM in the past is to ensure > > compatibility with the ARM proprietary, Clang based toolchain. At the > > time, we went with GNU ld, but I would actually prefer if we could > > make this work with LLD as well. > > Just to confirm, I'll keep lld for X64 and IA32, but I won't add > -fuse-ld=lld for ARM or AARCH64 since none of the toolchain definitions > currently do so. > > > The problem with trying to use lld for aarch64 is the following error: > > > GenFw: ERROR 3000: Invalid > WriteSections64(): > /home/bcran/uefi/edk2/Build/ArmVirtQemu-AARCH64/RELEASE_CLANGDWARF/AARCH64/ArmVirtPkg/MemoryInitPei/MemoryInitPeim/DEBUG/MemoryInit.dll > due to its size (> 1 MB), this module requires 4 KB section alignment. > That seems to be a false positive error in GenFw. It looks like LLD turns ADRP ADD into NOP ADR if the target is within -/+ 1 MiB but it doesn't update the relocations, so GenFw goes off into the weeds. I.e.. 304: d503201f nop 304: R_AARCH64_ADR_PREL_PG_HI21 .data 308: 100015c1 adr x1, 5c0 308: R_AARCH64_ADD_ABS_LO12_NC .data This is just another indication that using --emit-relocs is a bad idea, and we should really be building PIE executables and converting those based on the dynamic relocation instead. Adding -Wl,--no-relax to the DLINK flags should help with this, although I notice that there are other LLD related issues, in the ID map code I added to ArmVirtQemu a while ago, so ArmVirtQemu.dsc still does not build.