This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Long] Problem with ld


I need to put setup section right in the top of ELF file (within a 8192
bytes). However ld tries to rearrange the file structure.
--section-start do not change anything.

Script
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
virt = 0xC0000000;
SECTIONS
{
        . = phys;
        .setup : 
        {
                *(.setup)
        } 
        . += virt;
        . = ALIGN(0x1000);
        .text : AT(ADDR(.text) - virt)
        {
                code = .;
                phys_code = . - virt;
                *(.text)
        }
        . = ALIGN(0x1000);
        .data : AT(ADDR(.data) - virt)
        {
                data = .;
                phys_data = . - virt;
                *(.data)
        }
        . = ALIGN(0x1000);
        .bss : AT(ADDR(.bss) - virt)
        {
                bss = .;
                *(COMMON)
                *(.bss)
        }
        . = ALIGN(0x1000);
        end = .;
        phys_end = . - virt;
        phys = phys;
        virt = virt;
}

readelf:
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x100000
  Start of program headers:          52 (bytes into file)
  Start of section headers:          42820 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         18
  Section header string table index: 15

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00 0   0  0
  [ 1] .setup            PROGBITS        00100000 006008 00004e 00 0   0  4
  [ 2] .text             PROGBITS        c0101000 001000 002833 00  AX 0   0  4
  [ 3] .data             PROGBITS        c0104000 004000 002008 00  WA 0   0 4096
  [ 4] .bss              NOBITS          c0107000 006008 208110 00  WA 0   0 32
  [ 5] .debug_line       PROGBITS        00000000 006056 000692 00 0   0  1
  [ 6] .debug_info       PROGBITS        00000000 0066e8 001dc0 00 0   0  1
  [ 7] .debug_abbrev     PROGBITS        00000000 0084a8 000545 00 0   0  1
  [ 8] .debug_aranges    PROGBITS        00000000 0089f0 0000a8 00 0   0  8
  [ 9] .debug_ranges     PROGBITS        00000000 008a98 000020 00 0   0  8
  [10] .debug_frame      PROGBITS        00000000 008ab8 0005c4 00 0   0  4
  [11] .debug_loc        PROGBITS        00000000 00907c 000974 00 0   0  1
  [12] .debug_pubnames   PROGBITS        00000000 0099f0 0001b9 00 0   0  1
  [13] .debug_str        PROGBITS        00000000 009ba9 000a2b 01  MS 0   0  1
  [14] .comment          PROGBITS        00000000 00a5d4 0000bc 00 0   0  1
  [15] .shstrtab         STRTAB          00000000 00a690 0000b2 00 0   0  1
  [16] .symtab           SYMTAB          00000000 00aa14 0006e0 10 17  77  4
  [17] .strtab           STRTAB          00000000 00b0f4 0005c8 00 0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor
specific)

How to force lower offset for .setup.

PS. This script solves the problem - but it is rather a hack:
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
virt = 0xC0000000;
SECTIONS
{
        . = phys + virt;
        .text : AT(ADDR(.text) - virt)
        {
                *(.setup)
                . = ALIGN(0x1000);
                code = .;
                phys_code = . - virt;
                *(.text)
        } 
        . = ALIGN(0x1000);
        .data : AT(ADDR(.data) - virt)
        {
                data = .;
                phys_data = . - virt;
                *(.data)
        }
        . = ALIGN(0x1000);
        .bss : AT(ADDR(.bss) - virt)
        {
                bss = .;
                *(COMMON)
                *(.bss)
        }
        . = ALIGN(0x1000);
        end = .;
        phys_end = . - virt;
        phys = phys;
        virt = virt;
}

Regards
-- 
I've probably left my head... somewhere. Please wait untill I find it.
Homepage (pl_PL): http://uzytkownik.jogger.pl/
(GNU/)Linux User: #425935 (see http://counter.li.org/)



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]