From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1A407AC0911 for ; Tue, 15 Aug 2023 03:06:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=t9g5TaC/ynbRZNqtkZH6CMc9EihWeOIc2AcO3Twf81o=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:From:To:Cc:Subject:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1692068774; v=1; b=R/In2onPRRNPYotgkZIQmxvWhZZZxA3TqZ854558uxZyzgRpQ9Hx9X7tEo7l4Nd06CsCkM5D vhpC9iL6upqFQsIDUwB4aB+yO6aBZR+JI3xS4G945RC+HwE9+aoAWwklClZAri89S17w6DQMiWS /6fLBhVJniky54IVysbAiTcs= X-Received: by 127.0.0.2 with SMTP id APT3YY7687511x0yrpOsJGgO; Mon, 14 Aug 2023 20:06:14 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.126453.1692068772493950712 for ; Mon, 14 Aug 2023 20:06:13 -0700 X-Received: from loongson.cn (unknown [10.40.24.149]) by gateway (Coremail) with SMTP id _____8AxTeuh69pkEJsYAA--.45413S3; Tue, 15 Aug 2023 11:06:09 +0800 (CST) X-Received: from [10.40.24.149] (unknown [10.40.24.149]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx3yOg69pkkthaAA--.52164S3; Tue, 15 Aug 2023 11:06:09 +0800 (CST) Message-ID: <22642530-3177-d5d9-426a-d5a68ebfe8c6@loongson.cn> Date: Tue, 15 Aug 2023 11:06:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 From: "Chao Li" To: Liming Gao , Bob Feng , Yuwei Chen Cc: devel@edk2.groups.io Subject: [edk2-devel] About EDK2 supports Self Modifying Code X-CM-TRANSID: AQAAf8Bx3yOg69pkkthaAA--.52164S3 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAECGTZqbII0QABsz X-Coremail-Antispam: 1Uk129KBj93XoW7Jr4UAw47Kw4UXF47JFWUtrc_yoW8JrWUpF yY93sF9FyDAFW2g3s7tF109Fy093yfGrs7Jwn5JryDG345XFn2gFsYq3y3ta4UKw40yryj qr4jv34kC3y0yFXCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnRJUUUyGb4IE77IF4wAF F20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r 1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAF wI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv67 AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r4UJwAS0I0E0xvYzxvE52x0 82IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMcIj6xIIjxv20xvE14v26r106r15Mc Ij6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2 V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8Jw C20s026c02F40E14v26r106r1rMI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAF wI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjx v20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2 jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43 ZEXa7IU14rW5UUUUU== Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kqJTWF3BprSpNOK4yLrhXLACx7686176AA= Content-Type: multipart/alternative; boundary="------------dJBIlg003k3nGOv2T84ru0lL" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="R/In2onP"; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io --------------dJBIlg003k3nGOv2T84ru0lL Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Hi Liming, Bob and Yuwei There is a need that some code wants to supports Self-Modification,=20 because some program behavior may not be determined during compilation,=20 and I think this demand may be very popular. The permise of Self-Modification is that the section has executable and=20 writable permissions. Adding a new section and giving it executable and=20 writable permissions is a better way, and the 'pragma seg_code' is=20 recognized in Microsoft VS compiler but GCC doesn't. If use the GCC as=20 the compiler, the '.section name flags' of GNU GAS are acceptable. But there is a problem, if converting from elf to efi, the user-defined=20 section with W+X or A+W+X will be droped, Elf64Convert.c will scan the=20 file section permission of elf, if the section is A+X, it will be=20 classified into the .text section, if the section is A+W , then it will=20 be classified into the .data section, if the section is A+W+X or W+X,=20 then it will be droped(Elf64Convert.c, line 272 to 325). That is: If using the VS compiler, the user-defined with executable and writable=20 sections may be perserved, but GCC elf to efi conversion may not. Hope hearback from you and discuss the necessity of=20 SMC(Slef-Modifying-Code) and how to implement it. Thanks, Chao -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107759): https://edk2.groups.io/g/devel/message/107759 Mute This Topic: https://groups.io/mt/100751724/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --------------dJBIlg003k3nGOv2T84ru0lL Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

Hi Liming, Bob and Yuwei

There is a need that some code wants to supports Self-Modification, because some program behavior may not be determined during compilation, and I think this demand may be very popular.

The permise of Self-Modification is that the section has executable and writable permiss= ions. Adding a new section and giving it executable and writable permissions is a better way, and the 'pragma seg_code' is recognized in Microsoft VS compiler but GCC doesn't. If use the GCC as the compiler, the '.section name flags' of GNU GAS are acceptable.

But there is a problem, if converting from elf to efi, the user-defined section with W+X or A+W+X will be droped, Elf64Convert.c will scan the file section permission of elf, if the section is A+X, it will be classified into the .text section, if the section is A+W , then it will be classified into the .data section, if the section is A+W+X or W+X, then it will be droped(Elf64Convert.c, line 272 to 325).

That is:

If using the VS compiler, the user-defined with executable and writable sections may be perserved, but GCC elf to efi conversion may not.


Hope hearback from you and discuss the necessity of SMC(Slef-Modifying-Code) and how to implement it.



Thanks,
Chao
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#107759) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--------------dJBIlg003k3nGOv2T84ru0lL--