Gcc linker script question

I tried to get work my 30 years ago done protected mode ”nanokernel”.
Bootsector reads it from USB to the address 0x9000, earlier from floppy.
My old linker script does not work any more. I do not know how to construct a new script. The code is unchanged.
My development environment is given in the comment area at the beginning of the script which i have provided next:

/* 
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12)

Linux kernel: 4.15.0-142-generic #146~16.04.1-Ubuntu SMP

Ununtu 16.04/32 BIT system COMPILIED WITH FLAG -M32 TO BE SURE

MAKEFILE LD COMMAND: ld   $(OBJS)     -nostdlib -T $(LDS) -o wbs -M >map

ERROR MESSAGE:Makefile:21: recipe for target 'wbs' failed

Are * missing Some places meant to be everywhere before (.bss) (.text) (.data)
*/
MEMORY
{
        ram(rwx) : ORIGIN = 0x9000,LENGHT = 0x10000
}


SECTIONS
{

   .text_k:
        {
         init.o(.text)
        k_*(.text)
         } >ram:0x9000
    .data_k:
       { init*(.data)
        k_*(.data)
       } >ram:0xd000
     .bss_k: /*THIS IS LINE 21- ERROR? */
          {
       _bss_start = . ;
          init*(.bss)
          k_*(.bss)

        } > ram:0xe000

   _end = .;
   _size_of_kernel = _end - _start;

    process_start_base = .;

   .p0:
    {
    p0*(.text)
    p0*(.data)
    p0*(.bss)

    } >ram:0xf000
  .p1 :
    {
    p1*(.text)
    p1*(.data)
    p1*(.bss)

    } >ram:0xf400

.p2 :
    {

    p2*(.text)
    p2*(.data)
    p2*(.bss)

    } >ram:0xf800

.p3 :
    {

    p3*(.text)
    p3*(.data)
    p3*(.bss)

    } > ram:0xfc00
}

@Tuomo , welcome.

First off, I have no access to any environment that matches yours.
All feedback/comments purely based on ... divine luck :smiley:

Edited your initial post to use markdown tags covering ALL of the code not just bits of it.

Made a number of edits to your script, posted that at the end of this.

  • improve readablity/fix spelling/comment where appropriate.
MEMORY
{
    ram(rwx) : ORIGIN = 0x9000, LENGTH = 0x10000  /* fixed 'LENGHT' as it was misspelled */
}

SECTIONS
{
    .text_k : { init.o(.text) k_(.text) } > ram : 0x9000
    .data_k : { init(.data) k_*(.data) } > ram : 0xd000
    .bss_k  : { _bss_start = . ; init(.bss) k_(.bss) } > ram : 0xe000

    _end = .;
    _size_of_kernel = _end - _start;  /* _start not defined, do you mean _bss_start ?  */

    process_start_base = .;
    .p0 : { p0*(.text) p0*(.data) p0*(.bss) } > ram : 0xf000
    .p1 : { p1*(.text) p1*(.data) p1*(.bss) } > ram : 0xf400
    .p2 : { p2*(.text) p2*(.data) p2*(.bss) } > ram : 0xf800
    .p3 : { p3*(.text) p3*(.data) p3*(.bss) } > ram : 0xfc00
}

gnu ld documentation

you mention in your initial post ....
I do not know how to construct a new script , is that for the same environment or ??

Are * missing Some places meant to be everywhere before (.bss) (.text) (.data)
not really sure what you mean, perhaps '.text : { *(.text) }' which refers to ALL text sements, but, recommend you refer to the official documentation in all cases.

Sorry I could not be of any more (actual) assistance.

1 Like