copy_private_bfd_data in bfd/elf.c question

Steve Ellcey sje@cup.hp.com
Fri Jun 21 08:26:00 GMT 2002


> How about posting before/after output of readelf -S -l, so we can
> have a clue as to what is going on.

Ok, here is an example (on IA64 HP-UX) of using strip on a small
executable where the executable coredumps after being stripped.  This is
using the standard binutils without our local changes to
copy_private_bfd_data.

[hpadl731] $ cat x.c
main ()
{
        printf("hi\n");
}
[hpadl731] $ gcc x.c -o x
[hpadl731] $ ./x
hi
[hpadl731] $ readelf -S -I x
There are 33 section headers, starting at offset 0x1778:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 ffffffff 000000 00      0   0  0
  [ 1] .dynamic          DYNAMIC         04000178 000178 0000b8 08   A  0   0  8
  [ 2] .dynsym           DYNSYM          04000230 000230 0001a0 10   A  3   0  8
  [ 3] .dynstr           STRTAB          040003d0 0003d0 00024a 00   A  0   0  1
  [ 4] .hash             HASH            04000620 000620 0000a4 00   A  0   0  8
  [ 5] .rela.plt         RELA            040006c4 0006c4 00000c 0c   A  2   0  4
  [ 6] .IA_64.unwind_hdr PROGBITS        040006d0 0006d0 000018 00   A  0   0  8
  [ 7] .IA_64.unwind     IA_64_UNWIND    040006e8 0006e8 00000c 04   A  0   d  4
  [ 8] .IA_64.unwind_inf PROGBITS        040006f4 0006f4 000018 00   A  0   0  4
  [ 9] .rodata           PROGBITS        04000710 000710 000008 00   A  0   0  8
  [10] .interp           PROGBITS        04000718 000718 00002e 00   A  0   0  1
  [11] .dynhash          PROGBITS        04000748 000748 000068 00   A  0   0  8
  [12] .opd              PROGBITS        040007b0 0007b0 000000 00   A  0   0  8
  [13] .text             PROGBITS        040007b0 0007b0 000080 00  AX  0   0 16
  [14] .bortext          PROGBITS        04000830 000830 000040 00  AX  0   0 16
  [15] .data             PROGBITS        40000000 001000 000000 00  WA  0   0  1
  [16] .HP.init          PROGBITS        40000000 001000 000000 00  WA  0   0  4
  [17] .HP.preinit       PROGBITS        40000000 001000 000000 00  WA  0   0  4
  [18] .init_array       INIT_ARRAY      40000000 001000 000000 00  WA  0   0  4
  [19] .preinit_array    PREINIT_ARRAY   40000000 001000 000000 00  WA  0   0  4
  [20] .fini_array       FINI_ARRAY      40000000 001000 000000 00  WA  0   0  4
  [21] .plt              PROGBITS        40000000 001000 000010 10 WAp  0   0  8
  [22] .dlt              PROGBITS        40000010 001010 000008 08 WAp  0   0  8
  [23] .sbss             NOBITS          40000018 001018 000018 00 WAp  0   0  8
  [24] .bss              NOBITS          40000030 001018 000008 00  WA  0   0  8
  [25] .hbss             NOBITS          40000038 001018 000000 00  WA  0   0  8
  [26] .tbss             NOBITS          40000038 001018 000000 00 WAo  0   0  8
  [27] .fastbind         PROGBITS        00000000 001018 000000 00      0   0  1
  [28] .note             NOTE            00000000 001018 000098 00      0   0  4
  [29] .comment          PROGBITS        00000000 0010b0 000028 00      0   0  1
  [30] .strtab           STRTAB          00000000 0010d8 00020a 00      0   0  4
  [31] .symtab           SYMTAB          00000000 0012e8 000370 10     30  21  8
  [32] .shstrtab         STRTAB          00000000 001658 000120 00      0   0  4
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)

Histogram for bucket list length (total of 13 buckets):
 Length  Number     % of total  Coverage
      0  3          ( 23.1%)
      1  4          ( 30.8%)     19.0%
      2  2          ( 15.4%)     38.1%
      3  3          ( 23.1%)     81.0%
      4  1          (  7.7%)    100.0%

[hpadl731] $ strip x
[hpadl731] $ ./x
Memory fault(coredump)
[hpadl731] $ readelf -S -I x

There are 31 section headers, starting at offset 0x11e4:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .dynamic          DYNAMIC         04000178 000178 0000b8 08   A  3   0  8
  [ 2] .dynsym           DYNSYM          04000230 000230 0001a0 10   A  3   0  8
  [ 3] .dynstr           STRTAB          040003d0 0003d0 00024a 00   A  0   0  1
  [ 4] .hash             HASH            04000620 00061c 0000a4 04   A  2   0  8
  [ 5] .rela.plt         RELA            040006c4 0006c0 00000c 0c   A  2  15  4
  [ 6] .IA_64.unwind_hdr PROGBITS        040006d0 0006cc 000018 00   A  0   0  8
  [ 7] .IA_64.unwind     IA_64_UNWIND    040006e8 0006e4 00000c 04  AL 13   d  4
  [ 8] .IA_64.unwind_inf PROGBITS        040006f4 0006f0 000018 00   A  0   0  4
  [ 9] .rodata           PROGBITS        04000710 00070c 000008 00   A  0   0  8
  [10] .interp           PROGBITS        04000718 000714 00002e 00   A  0   0  1
  [11] .dynhash          PROGBITS        04000748 000744 000068 00   A  0   0  8
  [12] .opd              PROGBITS        040007b0 0007ac 000000 00   A  0   0  8
  [13] .text             PROGBITS        040007b0 0007ac 000080 00  AX  0   0 16
  [14] .bortext          PROGBITS        04000830 00082c 000040 00  AX  0   0 16
  [15] .data             PROGBITS        40000000 001000 000000 00  WA  0   0  1
  [16] .HP.init          PROGBITS        40000000 001000 000000 00  WA  0   0  4
  [17] .HP.preinit       PROGBITS        40000000 001000 000000 00  WA  0   0  4
  [18] .init_array       INIT_ARRAY      40000000 001000 000000 00  WA  0   0  4
  [19] .preinit_array    PREINIT_ARRAY   40000000 001000 000000 00  WA  0   0  4
  [20] .fini_array       FINI_ARRAY      40000000 001000 000000 00  WA  0   0  4
  [21] .plt              PROGBITS        40000000 001000 000010 10 WAp  0   0  8
  [22] .dlt              PROGBITS        40000010 001010 000008 08 WAp  0   0  8
  [23] .sbss             NOBITS          40000018 001018 000018 00 WAp  0   0  8
  [24] .bss              NOBITS          40000030 001018 000008 00  WA  0   0  8
  [25] .hbss             NOBITS          40000038 001018 000000 00  WA  0   0  8
  [26] .tbss             NOBITS          40000038 001018 000000 00  WA  0   0  8
  [27] .fastbind         PROGBITS        00000000 001018 000000 00      0   0  1
  [28] .note             NOTE            00000000 001018 000098 00      0   0  4
  [29] .comment          PROGBITS        00000000 0010b0 000028 00      0   0  1
  [30] .shstrtab         STRTAB          00000000 0010d8 00010b 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)

Histogram for bucket list length (total of 26 buckets):
 Length  Number     % of total  Coverage
      0  26         (100.0%)



More information about the Binutils mailing list