<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">We also support Xcode clang so that means we also support Mach-O executables that get converted to PE/COFF. The is a tool called mtoc (mach-o to coff) in a crufty old open source project that does the conversion. <div><br></div><div>The reason you are having issues is due to security hardening as the self modifying code is a security risk. It is kind of hard to imagine a case in UEFI that the self modifying code is worth the security risk?. I know Linux does some patching but those are really hot paths that get used a lot, I don’t see that being a pattern that would be common in firmware. The only case I can think you might want SMC is if you were trying to make an UEFI based stress test of some kind? </div><div><br></div><div>It might be helpful if you could explain why you can’t use a dispatch table or just define a UEFI Protocol and construct it on the fly to meet your configuration? To me saying you need Self Modifying Code is kind of like saying you need to write it in assembler since the C compiler is not smart enough, and most of the times people think that they are wrong.  <br><div><br></div><div>Thanks,</div><div><br></div><div>Andrew Fish<br><div><br><blockquote type="cite"><div>On Aug 14, 2023, at 8:06 PM, Chao Li <lichao@loongson.cn> wrote:</div><br class="Apple-interchange-newline"><div>
  

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  
  <div><p><font size="2">Hi Liming, Bob and Yuwei</font></p><p><font size="2">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. <br>
      </font></p><p><font size="2">The permise of Self-Modification is that the
        section has executable and writable </font><font size="2">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.</font></p><p><font size="2">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).</font></p><p><font size="2">That is:</font></p><p><font size="2">If using the VS compiler, the user-defined with
        executable and writable sections may be perserved, but GCC elf
        to efi conversion may not.</font></p><p><font size="2"><br>
      </font></p><p><font size="2">Hope hearback from you and discuss the necessity
        of SMC(Slef-Modifying-Code) and how to implement it.<br>
      </font></p><p><br>
    </p>
    <div class="moz-signature" signature-switch-id="18b8a24a-8ce6-4aca-a108-921eeebcd5e9"><br>
      <div style="width:15%;height:1px;background-color:grey;transform:scaleY(0.3)"></div>
      <div style="color:grey;font-size:11px">Thanks,<br>
        Chao<br>
      </div>
    </div>
  </div>





</div></blockquote></div><br></div></div></body></html>


<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>


Groups.io Links:<p>


  
    You receive all messages sent to this group.
  
  


<p>
<a target="_blank" href="https://edk2.groups.io/g/devel/message/107760">View/Reply Online (#107760)</a> |


  

|

  <a target="_blank" href="https://groups.io/mt/100751724/1813853">Mute This Topic</a>


| <a href="https://edk2.groups.io/g/devel/post">New Topic</a>

<br>




<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |

<a href="https://edk2.groups.io/g/devel/leave/3943202/1813853/130120423/xyzzy">Unsubscribe</a>

 [edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>