# "Shared object has no run-time symbol table" bug ?



## zero (Dec 12, 2010)

Hello,

I'm trying to code a tiny elf under freebsd, that means I'm writing its header in full assembler. But I've a little problem, this message, "Shared object has no run-time symbol table" appears when I'm trying to execute it.
The piece of code in the freebsd src is (/usr/src/libexec/rtld-elf/rtld.c:1771):

```
if (obj->nbuckets == 0 || obj->nchains == 0 || obj->buckets == NULL ||
    obj->symtab == NULL || obj->strtab == NULL) {
    _rtld_error("%s: Shared object has no run-time symbol table",
      obj->path);
    return -1;
}
```

Weirdly, my elf contains a strtab section.
Here is my code (sorry for the GAS syntax  ): http://pastebin.com/3hdXT2ha
And here is the result of readelf -a main:

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

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0] .text             PROGBITS        08048000 000000 0001b1 00  AX  0   0 16
  [ 1] .strtab           STRTAB          08048159 000159 00001f 00   A  0   0  1
  [ 2] .interp           PROGBITS        08048144 000144 000015 00   A  0   0  1
  [ 3] .dynsym           DYNSYM          08048134 000134 000010 10   A  5   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  Flg Align
  INTERP         0x000144 0x08048144 0x00000000 0x00015 0x00015 R   0x1
      [Requesting program interpreter: /libexec/ld-elf.so.1]
  LOAD           0x000000 0x08048000 0x00000000 0x001ad 0x001b1 RWE 0x1000
  DYNAMIC        0x000184 0x08048184 0x00000000 0x00024 0x00024 RW  0x4

 Section to Segment mapping:
  Segment Sections...
   00     .interp 
   01     .text .strtab .interp 
   02     

Dynamic segment at offset 0x184 contains 5 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
 0x00000005 (STRTAB)                     0x8048159
 0x00000006 (SYMTAB)                     0x0
 0x00000015 (DEBUG)                      0x0
 0x00000000 (NULL)                       0x0

There are no relocations in this file.

There are no unwind sections in this file.

Symbol table '.dynsym' contains 1 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND (null)

No version information found in this file.
```

We can clearly see the strtab.. So why the rtld don't find it.
*PS: my code works perfectly under Linux*


----------

