0xAX.github.io | 0xAX's blog - | Blog library
kandi X-RAY | 0xAX.github.io Summary
kandi X-RAY | 0xAX.github.io Summary
0xAX's blog
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of 0xAX.github.io
0xAX.github.io Key Features
0xAX.github.io Examples and Code Snippets
Community Discussions
Trending Discussions on 0xAX.github.io
QUESTION
I am trying to use a macro (as shown in this tutorial) to print a string. The macro PRINT
creates local labels to define the string content (str
) and length (strlen
), and then passes these as parameters to a second macro _syscall_write
which makes the syscall.
However running the code fails and I get a Segmentation fault (core dumped)
message.
I suspect the problem to be this particular lines, but I don't understand why.
...ANSWER
Answered 2019-Mar-09 at 01:35rex.W gs ins
is a privileged instruction, and faults in user-space. This is the first instruction of your program, from the expansion of %%str db %1, 0
in your macro without changing sections.
Don't put data where it will be executed as instructions; use section .rodata
for read-only data.
GAS would let you do .pushsection .rodata
/ .popsection
to expand the macro correctly inside any section, but for NASM I'm not sure if we can do better than unconditionally switch to section .text
after the data.
The NASM preprocessor has %push [optional context-name]
/ %pop
to save/restore preprocessor context, e.g. for nested repeat-until preprocessor stuff. But that's only for the preprocessor, and doesn't include restoring the old section
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install 0xAX.github.io
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page