bebbo / binutils-gdb

Unofficial mirror of sourceware binutils-gdb repository. Updated daily.
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git
GNU General Public License v2.0
3 stars 3 forks source link

Linker script does not support inserting data into sections #16

Closed michalsc closed 3 years ago

michalsc commented 3 years ago

According to manuals of GNU ld linker, I should be able to insert arbitrary data into sections by using BYTE, SHORT, LONG and QUAD expressions in linker script, e.g.:

    .text {
        LONG(0xdeadbeef)
    }

should generate .text section containing the 0xdeadbeef contents in the output file coming out from the linker. However, in case of m68k-amigaos-ld the only thing I become is a syntax error on the line which is using LONG, SHORT, BYTE or QUAD keyword.

Since this possibility is in many cases essential (e.g. by creating a ROM file with DiagArea + RomTag at the beginning) it would be great if the feature could be enabled.

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC20

bebbo commented 3 years ago

please test

michalsc commented 3 years ago

Shall I build everything from scratch? I ask because I have updated the amiga-gcc:

gmake update

and then I have triggered build of everything again:

gmake all NDK=3.2 SHELL=/usr/local/bin/bash

bfd successfully builds, however ld fails with following error:

gcc -DHAVE_CONFIG_H -I. -I/Users/michal/git/amiga-gcc/projects/binutils/ld  -I. -I/Users/michal/git/amiga-gcc/projects/binutils/ld -I../bfd -I/Users/michal/git/amiga-gcc/projects/binutils/ld/../bfd -I/Users/michal/git/amiga-gcc/projects/binutils/ld/../include -I/Users/michal/git/amiga-gcc/projects/binutils/ld/../zlib  -Os -DLOCALEDIR="\"/opt/amiga/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -DELF_LIST_OPTIONS=FALSE -DELF_SHLIB_LIST_OPTIONS=FALSE -DELF_PLT_UNWIND_LIST_OPTIONS=FALSE -Os -MT ldlex-wrapper.o -MD -MP -MF .deps/ldlex-wrapper.Tpo -c -o ldlex-wrapper.o /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c 
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:289:10: error: use of undeclared identifier 'FLOAT'; did you mean 'xFLOAT'?
{ RTOKEN(FLOAT);}
         ^~~~~
         xFLOAT
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:38: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                     ^
./ldgram.h:114:6: note: 'xFLOAT' declared here
     xFLOAT = 330,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:289:10: error: use of undeclared identifier 'FLOAT'; did you mean 'xFLOAT'?
{ RTOKEN(FLOAT);}
         ^~~~~
         xFLOAT
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:48: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                               ^
./ldgram.h:114:6: note: 'xFLOAT' declared here
     xFLOAT = 330,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:292:11: error: use of undeclared identifier 'LONG'; did you mean 'xLONG'?
{ RTOKEN( LONG);}
          ^~~~
          xLONG
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:38: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                     ^
./ldgram.h:68:6: note: 'xLONG' declared here
     xLONG = 284,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:292:11: error: use of undeclared identifier 'LONG'; did you mean 'xLONG'?
{ RTOKEN( LONG);}
          ^~~~
          xLONG
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:48: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                               ^
./ldgram.h:68:6: note: 'xLONG' declared here
     xLONG = 284,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:293:11: error: use of undeclared identifier 'SHORT'; did you mean 'xSHORT'?
{ RTOKEN( SHORT);}
          ^~~~~
          xSHORT
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:38: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                     ^
./ldgram.h:69:6: note: 'xSHORT' declared here
     xSHORT = 285,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:293:11: error: use of undeclared identifier 'SHORT'; did you mean 'xSHORT'?
{ RTOKEN( SHORT);}
          ^~~~~
          xSHORT
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:48: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                               ^
./ldgram.h:69:6: note: 'xSHORT' declared here
     xSHORT = 285,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:294:11: error: use of undeclared identifier 'BYTE'; did you mean 'xBYTE'?
{ RTOKEN( BYTE);}
          ^~~~
          xBYTE
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:38: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                     ^
./ldgram.h:70:6: note: 'xBYTE' declared here
     xBYTE = 286,
     ^
In file included from /Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex-wrapper.c:26:
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:294:11: error: use of undeclared identifier 'BYTE'; did you mean 'xBYTE'?
{ RTOKEN( BYTE);}
          ^~~~
          xBYTE
/Users/michal/git/amiga-gcc/projects/binutils/ld/ldlex.l:88:48: note: expanded from macro 'RTOKEN'
#define RTOKEN(x)  {  yylval.token = x; return x; }
                                               ^
./ldgram.h:70:6: note: 'xBYTE' declared here
     xBYTE = 286,
     ^
8 errors generated.
gmake[4]: *** [Makefile:2145: ldlex-wrapper.o] Error 1
make binutils ld...failed
bebbo commented 3 years ago

cleaning binutils is enough: make clean-binutils

michalsc commented 3 years ago

It is working perfectly now. Thanks. I'm closing the issue :-D