binutils-gdb/libctf
Nick Alcock 203bfa2f6b include, libctf, ld: extend variable section to contain functions too
The CTF variable section is an optional (usually-not-present) section in
the CTF dict which contains name -> type mappings corresponding to data
symbols that are present in the linker input but not in the output
symbol table: the idea is that programs that use their own symbol-
resolution mechanisms can use this section to look up the types of
symbols they have found using their own mechanism.

Because these removed symbols (mostly static variables, functions, etc)
all have names that are unlikely to appear in the ELF symtab and because
very few programs have their own symbol-resolution mechanisms, a special
linker flag (--ctf-variables) is needed to emit this section.

Historically, we emitted only removed data symbols into the variable
section.  This seemed to make sense at the time, but in hindsight it
really doesn't: functions are symbols too, and a C program can look them
up just like any other type.  So extend the variable section so that it
contains all static function symbols too (if it is emitted at all), with
types of kind CTF_K_FUNCTION.

This is a little fiddly.  We relied on compiler assistance for data
symbols: the compiler simply emits all data symbols twice, once into the
symtypetab as an indexed symbol and once into the variable section.

Rather than wait for a suitably adjusted compiler that does the same for
function symbols, we can pluck unreported function symbols out of the
symtab and add them to the variable section ourselves.  While we're at
it, we do the same with data symbols: this is redundant right now
because the compiler does it, but it costs very little time and lets the
compiler drop this kludge and save a little space in .o files.

include/
	* ctf.h: Mention the new things we can see in the variable
	section.

ld/
	* testsuite/ld-ctf/data-func-conflicted-vars.d: New test.

libctf/
	* ctf-link.c (ctf_link_deduplicating_variables): Duplicate
	symbols into the variable section too.
	* ctf-serialize.c (symtypetab_delete_nonstatic_vars): Rename
	to...
	(symtypetab_delete_nonstatics): ... this.  Check the funchash
	when pruning redundant variables.
	(ctf_symtypetab_sect_sizes): Adjust accordingly.
	* NEWS: Describe this change.
2022-03-23 13:48:32 +00:00
..
doc libctf: delete unused libctf_TEXINFOS 2022-02-11 04:20:49 -05:00
testsuite Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
.gitignore
aclocal.m4
ChangeLog Add markers for 2.38 branch 2022-01-22 12:08:55 +00:00
ChangeLog-2020
config.h.in
configure libctf: re-generate configure 2021-12-02 07:51:57 -05:00
configure.ac Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-archive.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-create.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-decl.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-decls.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-dedup.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-dump.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-endian.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-error.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-hash.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-impl.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-inlines.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-intl.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-labels.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-link.c include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
ctf-lookup.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-open-bfd.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-open.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-qsort_r.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-serialize.c include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
ctf-sha1.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-sha1.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-string.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-subr.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-types.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
ctf-util.c Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
elf.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
libctf.ver Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
Makefile.am Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30
Makefile.in libctf: delete unused libctf_TEXINFOS 2022-02-11 04:20:49 -05:00
NEWS include, libctf, ld: extend variable section to contain functions too 2022-03-23 13:48:32 +00:00
swap.h Update year range in copyright notice of binutils files 2022-01-02 12:04:28 +10:30