tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

libsa loadfile vs. short elf files



I'm not sure at what layer this is actually a bug - short story: some sparc64
kernels are not bootable. A non-bootable example output from readelf -e
is shown below, as well as a working one. The problem is: in the broken
case, we end up with libsa's MARK_DATA entry being == the MARK_START entry.
The sparc64 booter (ofwboot) does not deal properly with that.

I could make it deal with this easily, but I'd like to understand better if
this is a bug somewhere else (like in the kernel linker script) first (before
papering over it).

Any hints?

Thanks,

Martin

Bad example (note: just a single segment)

ELF Header:
  Magic:   7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Sparc v9
  Version:                           0x1
  Entry point address:               0x1009d88
  Start of program headers:          64 (bytes into file)
  Start of section headers:          4379360 (bytes into file)
  Flags:                             0x202, ultrasparcI, rmo
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         1
  Size of section headers:           64 (bytes)
  Number of section headers:         24
  Section header string table index: 21

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000001000000  00000080
       0000000000284d00  0000000000000000  AX       0     0     128
  [ 2] .rodata           PROGBITS         0000000001284d00  00284d80
       000000000003af88  0000000000000000   A       0     0     64
  [ 3] .rodata.str1.8    PROGBITS         00000000012bfc88  002bfd08
       0000000000047cc1  0000000000000001 AMS       0     0     8
  [ 4] link_set_malloc_t PROGBITS         0000000001307950  003079d0
       00000000000001f0  0000000000000000   A       0     0     8
  [ 5] link_set_ieee8021 PROGBITS         0000000001307b40  00307bc0
       0000000000000020  0000000000000000   A       0     0     8
  [ 6] link_set_sysctl_f PROGBITS         0000000001307b60  00307be0
       00000000000001a0  0000000000000000   A       0     0     8
  [ 7] link_set_pools    PROGBITS         0000000001307d00  00307d80
       00000000000000d8  0000000000000000   A       0     0     8
  [ 8] link_set_domains  PROGBITS         0000000001307dd8  00307e58
       0000000000000028  0000000000000000   A       0     0     8
  [ 9] .rodata.cst8      PROGBITS         0000000001307e00  00307e80
       0000000000000020  0000000000000008  AM       0     0     8
  [10] .rodata.cst4      PROGBITS         0000000001307e20  00307ea0
       0000000000000010  0000000000000004  AM       0     0     4
  [11] link_set_modules  PROGBITS         0000000001307e30  00307eb0
       0000000000000038  0000000000000000   A       0     0     8
  [12] link_set_evcnts   PROGBITS         0000000001307e68  00307ee8
       0000000000000038  0000000000000000   A       0     0     8
  [13] link_set_dkwedge_ PROGBITS         0000000001307ea0  00307f20
       0000000000000008  0000000000000000   A       0     0     8
  [14] link_set_bufq_str PROGBITS         0000000001307ea8  00307f28
       0000000000000018  0000000000000000   A       0     0     8
  [15] .data             PROGBITS         0000000001400000  00400080
       000000000001e550  0000000000000000  WA       0     0     32
  [16] .bss              NOBITS           000000000141e580  0041e5d0
       0000000000078c50  0000000000000000  WA       0     0     64
  [17] .comment          PROGBITS         0000000000000000  0041e5d0
       0000000000007ba8  0000000000000000           0     0     1
  [18] .note.netbsd.iden NOTE             000000000026c724  00426178
       0000000000000018  0000000000000000           0     0     4
  [19] .note             NOTE             0000000000000000  00426190
       0000000000000020  0000000000000000           0     0     4
  [20] .ident            PROGBITS         0000000000000000  004261b0
       0000000000006ff8  0000000000000000           0     0     1
  [21] .shstrtab         STRTAB           0000000000000000  0042d1a8
       0000000000000133  0000000000000000           0     0     1
  [22] .symtab           SYMTAB           0000000000000000  0042d8e0
       0000000000043020  0000000000000018          23   4105     8
  [23] .strtab           STRTAB           0000000000000000  00470900
       000000000002b8a7  0000000000000000           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)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000080 0x0000000001000000 0x0000000001000000
                 0x000000000041e550 0x00000000004971d0  RWE    80

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .rodata.str1.8 link_set_malloc_types 
link_set_ieee80211_funcs link_set_sysctl_funcs link_set_pools link_set_domains 
.rodata.cst8 .rodata.cst4 link_set_modules link_set_evcnts 
link_set_dkwedge_methods link_set_bufq_strats .data .bss 


And a good example:

ELF Header:
  Magic:   7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Sparc v9
  Version:                           0x1
  Entry point address:               0x1009550
  Start of program headers:          64 (bytes into file)
  Start of section headers:          7364824 (bytes into file)
  Flags:                             0x202, ultrasparcI, rmo
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         2
  Size of section headers:           64 (bytes)
  Number of section headers:         25
  Section header string table index: 22

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         0000000001000000  00000100
       00000000004be580  0000000000000000  AX       0     0     128
  [ 2] .rodata           PROGBITS         00000000014be580  004be680
       000000000015f000  0000000000000000   A       0     0     64
  [ 3] .rodata.str1.8    PROGBITS         000000000161d580  0061d680
       0000000000070c09  0000000000000001 AMS       0     0     8
  [ 4] link_set_malloc_t PROGBITS         000000000168e190  0068e290
       0000000000000260  0000000000000000   A       0     0     8
  [ 5] link_set_sysctl_f PROGBITS         000000000168e3f0  0068e4f0
       0000000000000230  0000000000000000   A       0     0     8
  [ 6] link_set_ieee8021 PROGBITS         000000000168e620  0068e720
       0000000000000020  0000000000000000   A       0     0     8
  [ 7] link_set_domains  PROGBITS         000000000168e640  0068e740
       0000000000000040  0000000000000000   A       0     0     8
  [ 8] link_set_pools    PROGBITS         000000000168e680  0068e780
       0000000000000118  0000000000000000   A       0     0     8
  [ 9] .rodata.cst4      PROGBITS         000000000168e798  0068e898
       000000000000002c  0000000000000004  AM       0     0     4
  [10] .rodata.cst2      PROGBITS         000000000168e7c4  0068e8c4
       0000000000000002  0000000000000002  AM       0     0     2
  [11] .rodata.cst8      PROGBITS         000000000168e7c8  0068e8c8
       00000000000000e8  0000000000000008  AM       0     0     8
  [12] link_set_modules  PROGBITS         000000000168e8b0  0068e9b0
       0000000000000090  0000000000000000   A       0     0     8
  [13] link_set_evcnts   PROGBITS         000000000168e940  0068ea40
       0000000000000038  0000000000000000   A       0     0     8
  [14] link_set_dkwedge_ PROGBITS         000000000168e978  0068ea78
       0000000000000008  0000000000000000   A       0     0     8
  [15] link_set_bufq_str PROGBITS         000000000168e980  0068ea80
       0000000000000018  0000000000000000   A       0     0     8
  [16] .data             PROGBITS         0000000001800000  0068eac0
       0000000000056f98  0000000000000000  WA       0     0     32
  [17] .bss              NOBITS           0000000001856fc0  006e5a58
       000000000007eeb8  0000000000000000  WA       0     0     64
  [18] .comment          PROGBITS         0000000000000000  006e5a58
       000000000001062c  0000000000000000           0     0     1
  [19] .note.netbsd.iden NOTE             000000000001062c  006f6084
       0000000000000018  0000000000000000           0     0     4
  [20] .note             NOTE             0000000000000000  006f609c
       0000000000000020  0000000000000000           0     0     4
  [21] .ident            PROGBITS         0000000000000000  006f60bc
       000000000000fed7  0000000000000000           0     0     1
  [22] .shstrtab         STRTAB           0000000000000000  00705f93
       0000000000000140  0000000000000000           0     0     1
  [23] .symtab           SYMTAB           0000000000000000  00706718
       000000000007dfe8  0000000000000018          24   9176     8
  [24] .strtab           STRTAB           0000000000000000  00784700
       0000000000050875  0000000000000000           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)

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000100 0x0000000001000000 0x0000000001000000
                 0x000000000068e998 0x000000000068e998  R E    80
  LOAD           0x000000000068eac0 0x0000000001800000 0x0000000001800000
                 0x0000000000056f98 0x00000000000d5e78  RW     40

 Section to Segment mapping:
  Segment Sections...
   00     .text .rodata .rodata.str1.8 link_set_malloc_types 
link_set_sysctl_funcs link_set_ieee80211_funcs link_set_domains link_set_pools 
.rodata.cst4 .rodata.cst2 .rodata.cst8 link_set_modules link_set_evcnts 
link_set_dkwedge_methods link_set_bufq_strats 
   01     .data .bss 



Home | Main Index | Thread Index | Old Index