Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 02 Feb 2021 14:26:44 +0000
From:      bugzilla-noreply@freebsd.org
To:        toolchain@FreeBSD.org
Subject:   [Bug 246015] readelf -S truncates section names
Message-ID:  <bug-246015-29464-UHWnrtwRX6@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-246015-29464@https.bugs.freebsd.org/bugzilla/>
References:  <bug-246015-29464@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D246015

--- Comment #1 from Ed Maste <emaste@freebsd.org> ---
Indeed, creating a test file via
$ objcopy -I binary -O elf64-x86-64 -B x86-64 --rename-section
.data=3D.this-is-a-really-long-name empty output.elf

ELF Tool Chain readelf by default shows:
$ readelf -S output.elf
There are 5 section headers, starting at offset 0x78:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .this-is-a-really PROGBITS         0000000000000000  00000040
       0000000000000000  0000000000000000  WA       0     0     1
  [ 2] .shstrtab         STRTAB           0000000000000000  00000040
       0000000000000038  0000000000000000           0     0     1
  [ 3] .symtab           SYMTAB           0000000000000000  000001b8
       0000000000000078  0000000000000018           4     2     8
  [ 4] .strtab           STRTAB           0000000000000000  00000230
       000000000000003a  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)

GNU readelf 2.33.1 shows:
$ /usr/local/bin/readelf -S output.elf
There are 5 section headers, starting at offset 0x78:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .this-is-a-really PROGBITS         0000000000000000  00000040
       0000000000000000  0000000000000000  WA       0     0     1
  [ 2] .shstrtab         STRTAB           0000000000000000  00000040
       0000000000000038  0000000000000000           0     0     1
  [ 3] .symtab           SYMTAB           0000000000000000  000001b8
       0000000000000078  0000000000000018           4     2     8
  [ 4] .strtab           STRTAB           0000000000000000  00000230
       000000000000003a  0000000000000000           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), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

(These differ only in the key.)

With -W GNU readelf shows:
$ /usr/local/bin/readelf -S -W output.elf=20
There are 5 section headers, starting at offset 0x78:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES =
Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00=
=20=20=20=20=20
0   0  0
  [ 1] .this-is-a-really-long-name PROGBITS        0000000000000000 000040
000000 00  WA  0   0  1
  [ 2] .shstrtab         STRTAB          0000000000000000 000040 000038 00=
=20=20=20=20=20
0   0  1
  [ 3] .symtab           SYMTAB          0000000000000000 0001b8 000078 18=
=20=20=20=20=20
4   2  8
  [ 4] .strtab           STRTAB          0000000000000000 000230 00003a 00=
=20=20=20=20=20
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), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  l (large), p (processor specific)

While ELF Tool Chain prints on one line but does not widen the name:

$ readelf -S -W output.elf
There are 5 section headers, starting at offset 0x78:

Section Headers:
  [Nr] Name              Type            Addr             Off    Size   ES =
Flg
Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00=
=20=20=20=20=20
0   0  0
  [ 1] .this-is-a-really PROGBITS        0000000000000000 000040 000000 00 =
 WA=20
0   0  1
  [ 2] .shstrtab         STRTAB          0000000000000000 000040 000038 00=
=20=20=20=20=20
0   0  1
  [ 3] .symtab           SYMTAB          0000000000000000 0001b8 000078 18=
=20=20=20=20=20
4   2  8
  [ 4] .strtab           STRTAB          0000000000000000 000230 00003a 00=
=20=20=20=20=20
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)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-246015-29464-UHWnrtwRX6>