assembly in c file without using gcc inline asm?
Posted: Fri Feb 26, 2021 2:09 am
I remember I've seen glibc did that before in the source code, but I forgot where.
The Place to Start for Operating System Developers
https://f.osdev.org/
Well, in my standard linker script, constant data is usually made part of the executable segment, so as long as you declare the array as constant it should work out. Though recently, binutils has shipped a new standard linker script that puts constant data into a nonexecutable segment, with the rationale of making it harder to find ROP gadgets. Of course, the additional page alignment overhead of this is pretty bad, especially for applications that try to limit memory consumption.iansjack wrote:I hadn't thought of that. But wouldn't that require your data pages to be executable, which doesn't seem like a good idea to me.
I'm sure that you are correct but, in any case, it doesn't seem to be a very useful way of including machine code into a C program unless you are looking at self-modifying code.nullplan wrote:Well, in my standard linker script, constant data is usually made part of the executable segment, so as long as you declare the array as constant it should work out. Though recently, binutils has shipped a new standard linker script that puts constant data into a nonexecutable segment, with the rationale of making it harder to find ROP gadgets. Of course, the additional page alignment overhead of this is pretty bad, especially for applications that try to limit memory consumption.iansjack wrote:I hadn't thought of that. But wouldn't that require your data pages to be executable, which doesn't seem like a good idea to me.