This is the mail archive of the binutils@sources.redhat.com 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]

Re: User defined sections




On 10 Oct 2001, Nick Clifton wrote:

> Hi Daniel,
> 
>   [Apologies for corrupting your name - my spelling checked barfed on
>    the accent!]

:)

No problem, I often need to write it without trema myself, there's a lot
of software which isn't aware of accents.

> > I'm trying to create a program with a custum section. This doesn't
> > seem to work; ld.so crashes on it.
> 
> First of all, this kind of problem should be reported to the binutils
> mailing list, since it is a linker problem.  I have redirected follow
> ups to there.

Thanks, I did search for a binutils mailinglist myself, but I couldn't
find one. So I tried the libc and gcc mailinglist; ld.so is  part of the
libc and gcc does have a lot to do with the binutils too.

> Secondly - how does ld.so crash ?

/opt/aolserver/servers/server1/pages/customsection> ./problem

Segmentatie fout
/opt/aolserver/servers/server1/pages/customsection> export LD_DEBUG=files
/opt/aolserver/servers/server1/pages/customsection> ./problem

Segmentatie fout
----

I can't get any debug information out it, the only thing that works is
export LD_DEBUG=help. The only thing that gdb reveals is that the segfault
has occured in ld.so.

> Thirdly - which versions of the tools are you using ?  In particular
> which version of ld are you using ?

Nasm 0.98
GNU ld 2.9.5
ld.so 2.1.3

> Fourthly - which target machine and which host OS are you using ?

Just a normal i386 (well k6 actually) running Linux 2.2.

> Did you include any extra switches when you configured and built the
> toolchain ?  What is your shoe size ?  No, sorry, ignore that last
> question.

Well, like most people I didn't compile the binutils myself. It's the
package shipped with SuSE 7.0. I have attached the output of objdump -i,
that gives a little informatin how it was build, I hope.

> > problem: problem.o image.o
> >         gcc -Xlinker -T -Xlinker link.res -o problem problem.o image.o
> 
> Does the linker produce any error or warning messages ?

No, it links without any objections.

> If you pass the "-M" option to the linker does the map it generates
> show you the sections being laid out as you expected.  How about
> running "readelf -a" on the resulting executable ?

Looks ok! I have attached the output of these commands.

Does it also crash on your system?

Greetings,

Daniël Mantione
BFD header file version 2.9.5.0.24
elf32-i386
 (header little endian, data little endian)
  i386
a.out-i386-linux
 (header little endian, data little endian)
  i386
elf32-little
 (header little endian, data little endian)
  i386
elf32-big
 (header big endian, data big endian)
  i386
srec
 (header endianness unknown, data endianness unknown)
  i386
symbolsrec
 (header endianness unknown, data endianness unknown)
  i386
tekhex
 (header endianness unknown, data endianness unknown)
  i386
binary
 (header endianness unknown, data endianness unknown)
  i386
ihex
 (header endianness unknown, data endianness unknown)
  i386
trad-core
 (header endianness unknown, data endianness unknown)

            elf32-i386 a.out-i386-linux elf32-little elf32-big srec symbolsrec 
       i386 elf32-i386 a.out-i386-linux elf32-little elf32-big srec symbolsrec 

            tekhex binary ihex trad-core 
       i386 tekhex binary ihex --------- 
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:               0x20000320
  Start of program headers:          52 (bytes into file)
  Start of section headers:          12676 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         30
  Section header string table index: 27

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00       0   0 0
  [ 1] .custom           PROGBITS        00000000 001000 000014 00 WAX   0   0 1
  [ 2] .interp           PROGBITS        200000f4 0010f4 000013 00   A   0   0 1
  [ 3] .note.ABI-tag     NOTE            20000108 001108 000020 00   A   0   0 4
  [ 4] .hash             HASH            20000128 001128 000030 04   A   5   0 4
  [ 5] .dynsym           DYNSYM          20000158 001158 000070 10   A   6   1 4
  [ 6] .dynstr           STRTAB          200001c8 0011c8 00007a 00   A   0   0 1
  [ 7] .gnu.version      VERSYM          20000242 001242 00000e 02   A   5   0 2
  [ 8] .gnu.version_r    VERNEED         20000250 001250 000020 00   A   6   1 4
  [ 9] .rel.got          REL             20000270 001270 000008 08   A   5  14 4
  [10] .rel.plt          REL             20000278 001278 000020 08   A   5   c 4
  [11] .init             PROGBITS        20000298 001298 000031 00  AX   0   0 4
  [12] .plt              PROGBITS        200002cc 0012cc 000050 04  AX   0   0 4
  [13] .text             PROGBITS        20000320 001320 00013c 00  AX   0   0 16
  [14] .fini             PROGBITS        2000045c 00145c 00001c 00  AX   0   0 4
  [15] .rodata           PROGBITS        20000480 001480 000054 00   A   0   0 32
  [16] .data             PROGBITS        200004d4 0014d4 00000c 00  WA   0   0 4
  [17] .eh_frame         PROGBITS        200004e0 0014e0 000004 00  WA   0   0 4
  [18] .ctors            PROGBITS        200004e4 0014e4 000008 00  WA   0   0 4
  [19] .dtors            PROGBITS        200004ec 0014ec 000008 00  WA   0   0 4
  [20] .got              PROGBITS        200004f4 0014f4 000020 04  WA   0   0 4
  [21] .dynamic          DYNAMIC         20000514 001514 0000a0 08  WA   6   0 4
  [22] .bss              NOBITS          200005b4 0015b4 000018 00  WA   0   0 4
  [23] .stab             PROGBITS        00000000 0015b4 000654 0c      24   0 4
  [24] .stabstr          STRTAB          00000000 001c08 001318 00       0   0 1
  [25] .comment          PROGBITS        00000000 002f20 000100 00       0   0 1
  [26] .note             NOTE            200005cc 003020 000078 00       0   0 1
  [27] .shstrtab         STRTAB          00000000 003098 0000eb 00       0   0 1
  [28] .symtab           SYMTAB          00000000 003634 000500 10      29  3d 4
  [29] .strtab           STRTAB          00000000 003b34 000225 00       0   0 1
Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings)
              I (info), L (link order), O (extra OS processing required)
              o (os specific), p (processor specific) x (unknown)

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00001034 0x00000000 0x000c0 0x000c0 R E 0x4
  INTERP         0x0010f4 0x200000f4 0x200000f4 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x001000 0x00000000 0x00000000 0x00014 0x00014 RWE 0x1000
  LOAD           0x0010f4 0x200000f4 0x200000f4 0x004c0 0x004d8 RWE 0x1000
  DYNAMIC        0x001514 0x20000514 0x20000514 0x000a0 0x000a0 RW  0x4
  NOTE           0x001108 0x20000108 0x20000108 0x00020 0x00020 R   0x4

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .custom 
   03     .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.got .rel.plt .init .plt .text .fini .rodata .data .eh_frame .ctors .dtors .got .dynamic .bss 
   04     .dynamic 
   05     .note.ABI-tag 

Dynamic segment at offset 0x1514 contains 20 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x20000298
 0x0000000d (FINI)                       0x2000045c
 0x00000004 (HASH)                       0x20000128
 0x00000005 (STRTAB)                     0x200001c8
 0x00000006 (SYMTAB)                     0x20000158
 0x0000000a (STRSZ)                      112 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x200004f4
 0x00000002 (PLTRELSZ)                   32 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x20000278
 0x00000011 (REL)                        0x20000270
 0x00000012 (RELSZ)                      8 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x20000250
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x20000242
 0x00000000 (NULL)                       0x0

Relocation section '.rel.got' at offset 0x1270 contains 1 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  20000510  00606 R_386_GLOB_DAT        00000000  __gmon_start__           

Relocation section '.rel.plt' at offset 0x1278 contains 4 entries:
  Offset    Info  Type            Symbol's Value  Symbol's Name
  20000500  00107 R_386_JUMP_SLOT       200002dc  __register_frame_info    
  20000504  00207 R_386_JUMP_SLOT       200002ec  __deregister_frame_info  
  20000508  00307 R_386_JUMP_SLOT       200002fc  __libc_start_main        
  2000050c  00407 R_386_JUMP_SLOT       2000030c  printf                   

Version symbols section '.gnu.version' contains 7 entries:
 Addr: 0000000020000242  Offset: 0x001242  Link: 5 (.dynsym)
gcc -Xlinker -M -Xlinker -T -Xlinker link.res -o problem problem.o image.o

Memory Configuration

Name             Origin             Length             Attributes
*default*        0x00000000         0xffffffff

Linker script and memory map

LOAD /usr/lib/crt1.o
LOAD /usr/lib/crti.o
LOAD /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
                0x00000000                .=0x0

.custom         0x00000000       0x14
 *(.custom)
 .custom        0x00000000       0x14 image.o
                0x200000f4                .=(0x20000000+SIZEOF_HEADERS)

.interp         0x200000f4       0x13
 *(.interp)
 .interp        0x200000f4       0x13 /usr/lib/crti.o

.note.ABI-tag   0x20000108       0x20
 .note.ABI-tag  0x20000108       0x20 /usr/lib/crt1.o

.hash           0x20000128       0x30
 *(.hash)
 .hash          0x20000128       0x30 /usr/lib/crti.o

.dynsym         0x20000158       0x70
 *(.dynsym)
 .dynsym        0x20000158       0x70 /usr/lib/crti.o

.dynstr         0x200001c8       0x7a
 *(.dynstr)
 .dynstr        0x200001c8       0x7a /usr/lib/crti.o

.gnu.version    0x20000242        0xe
 *(.gnu.version)
 .gnu.version   0x20000242        0xe /usr/lib/crti.o

.gnu.version_d  0x20000250        0x0
 *(.gnu.version_d)

.gnu.version_r  0x20000250       0x20
 *(.gnu.version_r)
 .gnu.version_r
                0x20000250       0x20 /usr/lib/crti.o

.rel.text
 *(.rel.text)
 *(.rel.gnu.linkonce.t*)

.rela.text
 *(.rela.text)
 *(.rela.gnu.linkonce.t*)

.rel.data
 *(.rel.data)
 *(.rel.gnu.linkonce.d*)

.rela.data
 *(.rela.data)
 *(.rela.gnu.linkonce.d*)

.rel.rodata
 *(.rel.rodata)
 *(.rel.gnu.linkonce.r*)

.rela.rodata
 *(.rela.rodata)
 *(.rela.gnu.linkonce.r*)

.rel.got        0x20000270        0x8
 *(.rel.got)
 .rel.got       0x20000270        0x8 /usr/lib/crti.o

.rela.got
 *(.rela.got)

.rel.ctors
 *(.rel.ctors)

.rela.ctors
 *(.rela.ctors)

.rel.dtors
 *(.rel.dtors)

.rela.dtors
 *(.rela.dtors)

.rel.init
 *(.rel.init)

.rela.init
 *(.rela.init)

.rel.fini
 *(.rel.fini)

.rela.fini
 *(.rela.fini)

.rel.bss        0x20000278        0x0
 *(.rel.bss)

.rela.bss
 *(.rela.bss)

.rel.plt        0x20000278       0x20
 *(.rel.plt)
 .rel.plt       0x20000278       0x20 /usr/lib/crti.o

.rela.plt
 *(.rela.plt)

.init           0x20000298       0x31
 *(.init)
 .init          0x20000298       0x24 /usr/lib/crti.o
                0x20000298                _init
 .init          0x200002bc        0x5 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .init          0x200002c1        0x5 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o
 .init          0x200002c6        0x3 /usr/lib/crtn.o

.plt            0x200002cc       0x50
 *(.plt)
 .plt           0x200002cc       0x50 /usr/lib/crti.o
                0x200002dc                __register_frame_info@@GLIBC_2.0
                0x200002ec                __deregister_frame_info@@GLIBC_2.0
                0x200002fc                __libc_start_main@@GLIBC_2.0
                0x2000030c                printf@@GLIBC_2.0

.text           0x20000320      0x13c
 *(.text)
 .text          0x20000320       0x24 /usr/lib/crt1.o
                0x20000320                _start
 *fill*         0x20000344        0xc
 .text          0x20000350       0xaa /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 *fill*         0x200003fa        0x6
 .text          0x20000400       0x1a problem.o
                0x20000400                main
 *fill*         0x2000041a        0x6
 .text          0x20000420       0x3a /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o
 *fill*         0x2000045a        0x2
                0x2000045c                _etext=.
                0x2000045c                PROVIDE (etext, .)
                0x2000045c                .=_etext

.fini           0x2000045c       0x1c
 *(.fini)
 .fini          0x2000045c       0x14 /usr/lib/crti.o
                0x2000045c                _fini
 .fini          0x20000470        0x5 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .fini          0x20000475        0x3 /usr/lib/crtn.o

.rodata         0x20000480       0x54
 *(.rodata)
 .rodata        0x20000480        0x8 /usr/lib/crt1.o
                0x20000484                _IO_stdin_used
 *fill*         0x20000488       0x18
 .rodata        0x200004a0       0x34 problem.o
 *(.gnu.linkonce.r*)

.rodata1
 *(.rodata1)
                0x200004d4                .=.

.data           0x200004d4        0xc
 *(.data)
 .data          0x200004d4        0x4 /usr/lib/crt1.o
                0x200004d4                data_start
                0x200004d4                __data_start
 .data          0x200004d8        0x8 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 *(.gnu.linkonce.d*)

.eh_frame       0x200004e0        0x4
 .eh_frame      0x200004e0        0x4 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o

.data1
 *(.data1)

.ctors          0x200004e4        0x8
 *(.ctors)
 .ctors         0x200004e4        0x4 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .ctors         0x200004e8        0x4 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o

.dtors          0x200004ec        0x8
 *(.dtors)
 .dtors         0x200004ec        0x4 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .dtors         0x200004f0        0x4 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o

.got            0x200004f4       0x20
 *(.got.plt)
 .got.plt       0x200004f4       0x1c /usr/lib/crti.o
                0x200004f4                _GLOBAL_OFFSET_TABLE_
 *(.got)
 .got           0x20000510        0x4 /usr/lib/crti.o

.dynamic        0x20000514       0xa0
 *(.dynamic)
 .dynamic       0x20000514       0xa0 /usr/lib/crti.o
                0x20000514                _DYNAMIC

.sdata
 *(.sdata)
                0x200005b4                _edata=.
                0x200005b4                PROVIDE (edata, .)
                0x200005b4                __bss_start=.

.sbss
 *(.sbss)
 *(.scommon)

.bss            0x200005b4       0x18
 *(.dynbss)
 *(.bss)
 .bss           0x200005b4       0x18 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 *(COMMON)
                0x200005cc                .=ALIGN(0x4)
                0x200005cc                _end=.
                0x200005cc                PROVIDE (end, .)

.stab           0x00000000      0x654
 *(.stab)
 .stab          0x00000000      0x654 /usr/lib/crt1.o
                                0x660 (size before relaxing)

.stabstr        0x00000000     0x1318
 *(.stabstr)
 .stabstr       0x00000000     0x1318 /usr/lib/crt1.o
                                  0x0 (size before relaxing)

.stab.excl
 *(.stab.excl)

.stab.exclstr
 *(.stab.exclstr)

.stab.index
 *(.stab.index)

.stab.indexstr
 *(.stab.indexstr)

.comment        0x00000000      0x100
 *(.comment)
 .comment       0x00000000       0x26 /usr/lib/crt1.o
 .comment       0x00000026       0x26 /usr/lib/crti.o
 .comment       0x0000004c       0x26 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .comment       0x00000072       0x26 problem.o
 .comment       0x00000098       0x1c image.o
 .comment       0x000000b4       0x26 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o
 .comment       0x000000da       0x26 /usr/lib/crtn.o

.debug
 *(.debug)

.line
 *(.line)

.debug_srcinfo
 *(.debug_srcinfo)

.debug_sfnames
 *(.debug_sfnames)

.debug_aranges
 *(.debug_aranges)

.debug_pubnames
 *(.debug_pubnames)

.debug_info
 *(.debug_info)

.debug_abbrev
 *(.debug_abbrev)

.debug_line
 *(.debug_line)

.debug_frame
 *(.debug_frame)

.debug_str
 *(.debug_str)

.debug_loc
 *(.debug_loc)

.debug_macinfo
 *(.debug_macinfo)

.debug_weaknames
 *(.debug_weaknames)

.debug_funcnames
 *(.debug_funcnames)

.debug_typenames
 *(.debug_typenames)

.debug_varnames
 *(.debug_varnames)
LOAD problem.o
LOAD image.o
LOAD /usr/lib/gcc-lib/i486-suse-linux/2.95.2/libgcc.a
LOAD /usr/lib/libc.so
START GROUP
LOAD /lib/libc.so.6
LOAD /usr/lib/libc_nonshared.a
END GROUP
LOAD /usr/lib/gcc-lib/i486-suse-linux/2.95.2/libgcc.a
LOAD /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o
LOAD /usr/lib/crtn.o
OUTPUT(problem elf32-i386)

.note           0x200005cc       0x78
 .note          0x200005cc       0x14 /usr/lib/crt1.o
 .note          0x200005e0       0x14 /usr/lib/crti.o
 .note          0x200005f4       0x14 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtbegin.o
 .note          0x20000608       0x14 problem.o
 .note          0x2000061c       0x14 /usr/lib/gcc-lib/i486-suse-linux/2.95.2/crtend.o
 .note          0x20000630       0x14 /usr/lib/crtn.o

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