Arm Community
Site
Search
User
Site
Search
User
Support forums
Arm Development Studio forum
gcc segment usage
Jump...
Cancel
Locked
Locked
Replies
4 replies
Subscribers
118 subscribers
Views
3470 views
Users
0 members are here
Options
Share
More actions
Cancel
Related
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion
gcc segment usage
Etienne SOBOLE
over 12 years ago
Note: This was originally posted on 17th April 2011 at
http://forums.arm.com
Hi!
With gcc, we have 4 segment:
.rodata : readonly data
.data : initialized global var
.bss : uninitialized global var
.text : assembler code source
To use ADR opcode, you have to put your data into .text segment.
For example
main:
push {r7, lr}
adr r0, .myString
bl printf
mov r0, #0
pop {r7, pc}
.myString:
.asciz "Hello\n"
I'd like to know (to be sure in fact) if you can't write into .text segment.
Ie, you can't write into r0 after the ADR instruction !
Can anybody confirm me that .text segment is read only ?
Parents
Alexander Shirshikov
over 12 years ago
Note: This was originally posted on 17th April 2011 at
http://forums.arm.com
You have to use readelf (in linux) to check it:
[14] .text PROGBITS 00000000004022c0 000022c0
0000000000010af8 0000000000000000 AX 0 0 16
There is "AX" and no "W" so yes, it is locked to write.
You could change these flags with mprotect or objcopy.
Also you can check /proc/$pid/maps of running binary to see a lot of stuff about it including permissions.
Cancel
Vote up
0
Vote down
Cancel
Reply
Alexander Shirshikov
over 12 years ago
Note: This was originally posted on 17th April 2011 at
http://forums.arm.com
You have to use readelf (in linux) to check it:
[14] .text PROGBITS 00000000004022c0 000022c0
0000000000010af8 0000000000000000 AX 0 0 16
There is "AX" and no "W" so yes, it is locked to write.
You could change these flags with mprotect or objcopy.
Also you can check /proc/$pid/maps of running binary to see a lot of stuff about it including permissions.
Cancel
Vote up
0
Vote down
Cancel
Children
No data