AmigaLabs / binutils-gdb

binutils targeted for ppc-amigaos systems (AmigaOS NG like OS4.1).
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
0 stars 0 forks source link

.text must not be writable #4

Closed kas1e closed 1 year ago

kas1e commented 1 year ago

Currently, we do have .text segment marked as writable:

Section Headers:
[ 1] .text PROGBITS 01000054 000054 00048c 00 WAX 0 0 4

But .text must not be writable. If elf.library ignores it for code it may not be a problem, but if it doesn't and allocates the code in writable memory it's a problem.

kas1e commented 1 year ago

More info about issue:

This is happening with ALL binutils ever released for amigaos4, be it last ones, adtools ones, or 20 years old 2.14 ones . The problems seems to be because of prebuild ldscripts used for build amigaos4 binaries.

Once i use my own ldscript, like:

SECTIONS
 {
   . = SIZEOF_HEADERS;
   .text           : { *(.text) }
 }

and compile it like:

 ppc-amigaos-ld -Tldscript -q test_new.o -o test_new /usr/local/amiga/ppc-amigaos/SDK/newlib/lib/crtbegin.o /usr/local/amiga/ppc-amigaos/SDK/newlib/lib/LibC.a /usr/local/amiga/ppc-amigaos/SDK/newlib/lib/crtend.o

Then, .text segment is AX, and not WAX.

But if i didn't provide any ldscript (so default ones used), then we always have WAX for .text segment.

So this is perhaps an issue with prebuild ldscripts.

kas1e commented 1 year ago

Turns out it was a false alarm. The problem was that i use "-N" swith for LD , which i just copied from my old hacking-tests, and this -N swith mean exactly to make .text to be writable.

So, new binutils generate it all correct once -N ommited (and if use GCC11 binary, it also works fine).