MSVC++ - Force everything to be put into a single section except for `.reloc`
I've tried using Microsoft Visual C++ #pragma section( ".text" )
开发者_如何转开发 and __declspec(allocate(".text"))
on static read-only string data. But there is still a .rdata
section in the binary. I am NOT using the standard C libraries. I am using MSVC++ as a bytecode compiler for use with code injection.
It would greatly simplify injection by having read-only data inside the ".text" section and not the ".rdata" section. How can I do that? is there a linker option to stuff everything into one single section, or merge 2 sections together?
There is a merge sections
option in the Microsoft linker. This looks like it will work for my purposes. /MERGE:[from=to]
Put all strings and other static data in stack manually.
So you don't need other sections, except .text.
char String[] = { 's', 't', 'r', 'i', 'n', 'g', 0 };
And Unicode:
wchar_t WideString[] = { L'H', L'e', L'l', L'l', L'o', L'\0' };
精彩评论