]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
bfd: new functions for getting strings out of a strtab
authorNick Alcock <nick.alcock@oracle.com>
Sat, 13 Jul 2019 20:47:30 +0000 (21:47 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Mon, 23 Sep 2019 13:12:54 +0000 (14:12 +0100)
commitbc02cd7f56dbc53f941b3e243b57c6448efd6f4d
tree718beda6aa936d94fcc37bc5db3d9eae4b5de737
parentbf05b84eda6ea5e903ed19fad4e509eca43a7267
bfd: new functions for getting strings out of a strtab

The CTF linking process wants to deduplicate the CTF strtab against the
ELF strtab, for which it needs to know the number of strings in the
strtab and it needs to be able to extract them one by one.

The BFD strtab functions only support returning the
size-or-section-length of the strtab (with _bfd_elf_strtab_size)
and returning the offset (but not string!) and decrementing the refcount
at the same time.

So add new functions _bfd_elf_strtab_len (that just returns the length
in strings of the strtab, never the section size) and bfd_elf_strtab_str
(which returns the string at a given strtab index, and its offset,
without touching the refcount).

It is probably a mistake to use _bfd_elf_strtab_str in particular before
_bfd_elf_strtab_finalize is called, and will not produce useful output
if you do so.

bfd/
* elf-strtab.c (_bfd_elf_strtab_len): New.
(_bfd_elf_strtab_str): Likewise.
* bfd-elf.h: Declare them.
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-strtab.c