[oss] [Lab 02][Task 5] mark .data as executable
Alex Teaca
ionutalex.teaca at gmail.com
Sun Oct 26 14:10:32 EET 2014
Hi Lucian,
Yes, the 'section .data exec' in the .asm file works for me too.
But this solution assumes that you are compiling with the nasm an .asm
file, right ?
The idea was to be able to do this thing by starting from a C source. And
converting
from .s file obtained with the gcc compiler into an .asm file is not very
natural and easy.
I think the syntax for the gcc compiler applied to the .s file
should be: `.section .data,"x", at progbits`, but the compiler does not like
it and will warn:
main.s: Assembler messages:
main.s:2: Warning: ignoring changed section attributes for .data
I mean, if you want the stack executable and add in the .s file '.section
.note.GNU-stack,"x", at progbits'
works, but for .data section does not.
Thanks, Alex
On Sun, Oct 26, 2014 at 11:08 AM, Lucian Mogosanu <lucian.mogosanu at cs.pub.ro
> wrote:
> On Sat, Oct 25, 2014 at 05:06:17PM +0300, Alex Teaca wrote:
> > Also, I tried to compile with -S flag, and update the task5.s with
> > ".section .data,"awx", at progbits"
> > but, when I compile, I get
> >
> > gcc -C task5.s
> > test5.s: Assembler messages:
> > test5.s:5: Warning: ignoring changed section attributes for .data
> >
> > and the .data section remains WA.
>
> I managed to make .data executable with NASM, with a little help from the
> documentation [1]: I added the `exec` directive to .data on hello.asm, and
> now
> readelf -S gives me the following output:
>
> ---
> There are 15 section headers, starting at offset 0x2d4:
>
> Section Headers:
> [...]
> [ 9] .text PROGBITS 08048190 000190 00000a 00 AX 0
> 0 16
> [10] .eh_frame PROGBITS 0804819c 00019c 000000 00 A 0
> 0 4
> [11] .dynamic DYNAMIC 0804919c 00019c 0000a0 08 WA 4
> 0 4
> [12] .got.plt PROGBITS 0804923c 00023c 000010 04 WA 0
> 0 4
> [13] .data PROGBITS 0804924c 00024c 00000e 00 WAX 0
> 0 4
> [...]
> ---
>
> Does that work for you?
>
> [1]: http://www.nasm.us/doc/nasmdoc7.html#section-7.9.2
>
> Lucian
> _______________________________________________
> http://elf.cs.pub.ro/oss/wiki/resources/mailing-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/oss/attachments/20141026/935bec24/attachment.html>
More information about the oss
mailing list