From nobody Tue Apr 23 20:06:57 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1595432260; cv=none; d=zohomail.com; s=zohoarc; b=eyK0GCHQsTG+3ZjNvdddwcROSkmop/XGIr5LfwEuaRsPFBGmboGvVyq3IQj21s+3XRGhvFQOvZZ3iyIagtcciYllOITzZBvH5CYe4gK3qIz2n5Wg+FyCi0aBYuK82aulCzwCECHhCx9wXobdDBek2Fsd8dg5ULhIs7TqbWPdYdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595432260; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Subject:To; bh=kJlHlBLoHumJ/q4q/KqJwqBI7ENknmKqpg0NcEwYLno=; b=lakpEAMOX4bhTbZcSN79QdFRW+Yxd7qgabG1jD/Y8NOh68dkXYFZjNPTCfaKRSMoqHku66zv2U44MkUy1rtVbbAlgVuDVlxQ4d0rVOEwVaHJt6SKWn9PwF24MKQsy8u+6HS1VtxxRwIQKRlXYPqyMZZEDoat0LV53WuFacjMOrI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 78.46.105.101 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1595432260185564.4347905731724; Wed, 22 Jul 2020 08:37:40 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 575AD10C15CD; Wed, 22 Jul 2020 15:37:36 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id C28EB10C15C9 for ; Wed, 22 Jul 2020 15:37:21 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) for ; Wed, 22 Jul 2020 08:37:21 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by smtp.gmail.com with ESMTPSA id z24sm38547qtn.7.2020.07.22.08.37.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 08:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=koconnor.net; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=kMD47uTYcc4BC5GS1DPDZoai45ypC0uzmfq3GJlyk/8=; b=Y7fNWiVh2Imxm6eEanHPCEbuS/rcMI5srCqny2l85e3cJa/0EW89S2OLdTvNDdEh8Y EiMQdz/mqibnatufFScEq62QNjsgNzeN8H2hJt2xZLPlaIwiRe+Jpr7fvjXDSxgZtn8h 7EzvCQwTl4XlMDRn8P15VBK5gg3tBxEGw0lUU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=kMD47uTYcc4BC5GS1DPDZoai45ypC0uzmfq3GJlyk/8=; b=ucD81Y7/b3g8psFnOPpaFWIu+7JGTNz/JDkB1MGl1Iwe1E0yBYj2xmBLQJArrkgubX eH5bRWaCGLZTOAf8OTYpu7HdFnfTTg1PKbVRc+riZgVPUlIaT6AKS2OGEkMI+2QvnJZl GBz+FRXKYj7mjC0a9okI3WM+17WhdOpuEaQ0X5zIcpSmB+ZWEa8AvZsSaLuhbcnhNCls R/iw2ljFO5eE6j9YyfJfAooi1Ttu9NUgsxTOLuiw8482Uwd0NXa1r41su8JrchPpeRXW rDVuq6LJEg+AiUsaEuJHURls5xEFIhCaFZzcn8xM5GUQMI63tu7S6txBMrI6sC9MdBdk VMPg== X-Gm-Message-State: AOAM5320mRdka/mTegopIx1EXq7WsYOktlB/f07kqXPhYJ+0jch8ECCX dDbpL6z8gGbbv8tlx1zof36AmqCdtmY= X-Google-Smtp-Source: ABdhPJxTUpoko6rjpC2FdO7a3Fm8SriEfw3ZIzObgbyPwytqWZgH9rHrNW2CJHH08rzP4M1P+nGlWQ== X-Received: by 2002:a05:6214:4c4:: with SMTP id ck4mr571045qvb.202.1595432239712; Wed, 22 Jul 2020 08:37:19 -0700 (PDT) From: Kevin O'Connor To: seabios@seabios.org Date: Wed, 22 Jul 2020 11:37:16 -0400 Message-Id: <20200722153716.2772583-1-kevin@koconnor.net> MIME-Version: 1.0 X-Spam-Level: *** Message-ID-Hash: 5VKRB6X34TJLWCKLNJ76HKZ5MEMQHAYV X-Message-ID-Hash: 5VKRB6X34TJLWCKLNJ76HKZ5MEMQHAYV X-MailFrom: kevin@koconnor.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.3.2b1 Precedence: list Subject: [SeaBIOS] [PATCH] ldnoexec: Add script to remove ET_EXEC flag from intermediate build objects List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: -- X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a script to remove the ET_EXEC flag from the 16bit and "32bit segmented" intermediate objects. This avoids build failures with some linkers that will not allow linking these objects again. Signed-off-by: Kevin O'Connor --- Makefile | 9 +++++---- scripts/ldnoexec.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 scripts/ldnoexec.py diff --git a/Makefile b/Makefile index c20be15..3d8943e 100644 --- a/Makefile +++ b/Makefile @@ -127,9 +127,10 @@ $(Q)printf '$(foreach i,$2,#include "$i"\n)' > $3.tmp.c $(Q)$(CC) -I. $1 $(CFLAGSWHOLE) -c $3.tmp.c -o $3 endef =20 -%.strip.o: %.o +%.noexec.o: %.o @echo " Stripping $@" - $(Q)$(STRIP) $< -o $@ + $(Q)$(STRIP) $< -o $<.strip.o + $(Q)$(PYTHON) ./scripts/ldnoexec.py $<.strip.o $@ =20 $(OUT)%.s: %.c @echo " Compiling to assembler $@" @@ -185,9 +186,9 @@ $(OUT)rom32seg.o: $(OUT)code32seg.o $(OUT)romlayout32se= g.lds @echo " Linking $@" $(Q)$(LD) -T $(OUT)romlayout32seg.lds $< -o $@ =20 -$(OUT)rom.o: $(OUT)rom16.strip.o $(OUT)rom32seg.strip.o $(OUT)code32flat.o= $(OUT)romlayout32flat.lds +$(OUT)rom.o: $(OUT)rom16.noexec.o $(OUT)rom32seg.noexec.o $(OUT)code32flat= .o $(OUT)romlayout32flat.lds @echo " Linking $@" - $(Q)$(LD) -N -T $(OUT)romlayout32flat.lds $(OUT)rom16.strip.o $(OUT)rom32= seg.strip.o $(OUT)code32flat.o -o $@ + $(Q)$(LD) -N -T $(OUT)romlayout32flat.lds $(OUT)rom16.noexec.o $(OUT)rom3= 2seg.noexec.o $(OUT)code32flat.o -o $@ =20 $(OUT)bios.bin.prep: $(OUT)rom.o scripts/checkrom.py @echo " Prepping $@" diff --git a/scripts/ldnoexec.py b/scripts/ldnoexec.py new file mode 100755 index 0000000..b0b32d4 --- /dev/null +++ b/scripts/ldnoexec.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python2 +# Script to remove EXEC flag from an ELF file +# +# Copyright (C) 2020 Kevin O'Connor +# +# This file may be distributed under the terms of the GNU GPLv3 license. +import os, optparse, sys + +FLAG_OFFSET =3D 16 + +def main(): + # Parse command-line arguments + usage =3D "%prog " + opts =3D optparse.OptionParser(usage) + options, args =3D opts.parse_args() + if len(args) !=3D 2: + opts.error("Incorrect number of arguments") + infilename, outfilename =3D args + # Read input + f =3D open(infilename, "rb") + srcdata =3D f.read() + f.close() + # Update + outdata =3D bytearray(srcdata) + outdata[FLAG_OFFSET] =3D 0x01 # change ET_EXEC to ET_REL + # Write output + f =3D open(outfilename, "wb") + f.write(outdata) + f.close() + +if __name__ =3D=3D '__main__': + main() --=20 2.26.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org