How to Safely Modify .byte Values in x86_64 Assembly Without Segmentation Faults

I need to modify specific .byte values using the inc instruction in a small x86 64 asm project . I want to increment the values of .byte 0x0d and .byte 0x04 in my code to change them to .byte 0x0f and .byte 0x05, respectively. I expect to increment the .byte values by using inc byte ptr [rip+offset] to modify the bytes at the correct memory offsets. So when I run the code, I encounter a SIGSEGV, a segmentation fault at the inc instructions, even though I verified the offsets using objdump and confirmed that they are correct I also tried using:
lea r11, [_start]
lea r11, [_start]
To load the address of _start and manually adjust the byte values, but this approach didn’t work when assembling the code. Why am I getting a segmentation fault SIGSEGV when trying to modify these .byte values with inc byte ptr [rip+offset]? Is there a better or safer way to modify .byte values directly in assembly , I don't quite know rip relative addressing . How can I achieve this modification without causing a crash?
attachment 0
Solution:
You're getting a SIGSEGV because .byte values are in the code section, which is read-only. You cannot modify them directly with inc. store them in a writable data section like .data or .bss, then modify them using the correct addressing mode.
Jump to solution
3 Replies
Solution
wafa_ath
wafa_ath3mo ago
You're getting a SIGSEGV because .byte values are in the code section, which is read-only. You cannot modify them directly with inc. store them in a writable data section like .data or .bss, then modify them using the correct addressing mode.
Marvee Amasi
Marvee Amasi3mo ago
Thanks a lot
Want results from more Discord servers?
Add your server