From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web10.4754.1682052346233233357 for ; Thu, 20 Apr 2023 21:45:46 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QzhDPMQ3; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682052344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jzsE1C7fnfXiPLcsAthyq06y04TFVFQzJbhb7OusspM=; b=QzhDPMQ3fScToHGmDAjJXmAHbbtXQE6cEhcfNfHfwYxE+ZLcwoWQFN6QV1ao0e5yYq7ONe mlc3BWfV9oXd6aC5xgzdI8qDdbWBs5/ikhsX/Qc/VbGkLYAbpEwRmwTpN1AhFKG8zXTNja 4O6SoUjsx+Car0M3sdcFTN41RWvJgmA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-3aatJEutOByRouuTwaHICQ-1; Fri, 21 Apr 2023 00:45:38 -0400 X-MC-Unique: 3aatJEutOByRouuTwaHICQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6BEF93C0E239; Fri, 21 Apr 2023 04:45:37 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 995BA63A5D; Fri, 21 Apr 2023 04:45:36 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 606161800084; Fri, 21 Apr 2023 06:45:35 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Yuwei Chen , Oliver Steffen , Bob Feng , =?UTF-8?q?Marvin=20H=C3=A4user?= , Daniel Schaefer , Chao Li , Dongyan Qian , Michael D Kinney , Pawel Polawski , Baoqi Zhang , Leif Lindholm , Rebecca Cran , Zhiguang Liu , Sunil V L , Ard Biesheuvel , Liming Gao , Gerd Hoffmann , Ard Biesheuvel Subject: [PATCH v5 01/10] BaseTools: make sure the got is empty Date: Fri, 21 Apr 2023 06:45:26 +0200 Message-Id: <20230421044535.4030762-2-kraxel@redhat.com> In-Reply-To: <20230421044535.4030762-1-kraxel@redhat.com> References: <20230421044535.4030762-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Add ASSERT()s that .got and .got.plt sections are empty to linker scripts for gcc and clang. Suggested-by: Ard Biesheuvel Signed-off-by: Gerd Hoffmann --- BaseTools/Scripts/ClangBase.lds | 10 ++++++++++ BaseTools/Scripts/GccBase.lds | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/BaseTools/Scripts/ClangBase.lds b/BaseTools/Scripts/ClangBase.lds index 61452ddd9506..c7dcd2024ac8 100644 --- a/BaseTools/Scripts/ClangBase.lds +++ b/BaseTools/Scripts/ClangBase.lds @@ -59,6 +59,16 @@ SECTIONS { KEEP (*(.hii)) } + .got : { + *(.got) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + + .got.plt (INFO) : { + *(.got.plt) + } + ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") + /* * Retain the GNU build id but in a non-allocatable section so GenFw * does not copy it into the PE/COFF image. diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds index 83cebd29d599..9f27e83bb0fc 100644 --- a/BaseTools/Scripts/GccBase.lds +++ b/BaseTools/Scripts/GccBase.lds @@ -59,6 +59,16 @@ SECTIONS { KEEP (*(.hii)) } + .got : { + *(.got) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + + .got.plt (INFO) : { + *(.got.plt) + } + ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") + /* * Retain the GNU build id but in a non-allocatable section so GenFw * does not copy it into the PE/COFF image. -- 2.40.0