Author Topic: Feature suggestion for the GoLink linker  (Read 91 times)

Ben321

  • Regular Member
  • *
  • Posts: 17
Feature suggestion for the GoLink linker
« on: July 12, 2020, 09:45:40 PM »
I emailed the author of the Go tools with this suggestion, but I've not heard back from him yet. I don't even know if he checks his email, so I'm posting the suggestion here now, hoping he reads it.

I would like to see the ability to override default section flags in the output file, for example setting the ".text" section of an EXE file to not be read-only. This would allow for making self-modifying EXEs or DLLs. I propose the following commandline switches for GoLink.

/sar (section allow read)
/sdr (section disallow read)
/saw (section allow write)
/sdw (section disallow write)
/scw (section copy on write)
/sae (section allow execution)
/sde (section disallow execution)

The format would be the switch, followed by the section name (which is case sensitive, if I'm not mistaken).
For example, if you wanted to allow writing to the code section (called .text), you would use the command line switch as below.
/saw .text

Vortex

  • Member
  • *****
  • Posts: 2271
Re: Feature suggestion for the GoLink linker
« Reply #1 on: July 13, 2020, 09:11:25 PM »
Hello,

As a quick solution : MS Link coming with the Masm32 installation is providing the section modification capability :

Code: [Select]
C:\masm32\bin>link.exe /? | findstr "SECTION"
      /SECTION:name,[E][R][W][S][D][K][L][P][X]

https://docs.microsoft.com/en-us/cpp/build/reference/section-specify-section-attributes?view=vs-2015