[edk2-devel] About EDK2 supports Self Modifying Code

Chao Li lichao at loongson.cn
Tue Aug 15 03:06:08 UTC 2023


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 permissions. 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: 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/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20230815/fa991f56/attachment-0001.htm>


More information about the edk2-devel-archive mailing list