diff options
author | Nick Alcock <nick.alcock@oracle.com> | 2019-07-13 21:06:55 +0100 |
---|---|---|
committer | Nick Alcock <nick.alcock@oracle.com> | 2019-10-03 17:04:55 +0100 |
commit | 72c83edd92ef15a19ed0c033e25bb5006ee3bdd8 (patch) | |
tree | 6fc2904033510fc4e2d60ce2036ad9cb11baede9 /libctf/Makefile.in | |
parent | d18f9f16299170e94a3d2e8a45aa349a25278aa3 (diff) | |
download | gdb-72c83edd92ef15a19ed0c033e25bb5006ee3bdd8.zip gdb-72c83edd92ef15a19ed0c033e25bb5006ee3bdd8.tar.gz gdb-72c83edd92ef15a19ed0c033e25bb5006ee3bdd8.tar.bz2 |
libctf: add the ctf_link machinery
This is the start of work on the core of the linking mechanism for CTF
sections. This commit handles the type and string sections.
The linker calls these functions in sequence:
ctf_link_add_ctf: to add each CTF section in the input in turn to a
newly-created ctf_file_t (which will appear in the output, and which
itself will become the shared parent that contains types that all
TUs have in common (in all link modes) and all types that do not
have conflicting definitions between types (by default). Input files
that are themselves products of ld -r are supported, though this is
not heavily tested yet.
ctf_link: called once all input files are added to merge the types in
all the input containers into the output container, eliminating
duplicates.
ctf_link_add_strtab: called once the ELF string table is finalized and
all its offsets are known, this calls a callback provided by the
linker which returns the string content and offset of every string in
the ELF strtab in turn: all these strings which appear in the input
CTF strtab are eliminated from it in favour of the ELF strtab:
equally, any strings that only appear in the input strtab will
reappear in the internal CTF strtab of the output.
ctf_link_shuffle_syms (not yet implemented): called once the ELF symtab
is finalized, this calls a callback provided by the linker which
returns information on every symbol in turn as a ctf_link_sym_t. This
is then used to shuffle the function info and data object sections in
the CTF section into symbol table order, eliminating the index
sections which map those sections to symbol names before that point.
Currently just returns ECTF_NOTYET.
ctf_link_write: Returns a buffer containing either a serialized
ctf_file_t (if there are no types with conflicting definitions in the
object files in the link) or a ctf_archive_t containing a large
ctf_file_t (the common types) and a bunch of small ones named after
individual CUs in which conflicting types are found (containing the
conflicting types, and all types that reference them). A threshold
size above which compression takes place is passed as one parameter.
(Currently, only gzip compression is supported, but I hope to add lzma
as well.)
Lifetime rules for this are simple: don't close the input CTF files
until you've called ctf_link for the last time. We do not assume
that symbols or strings passed in by the callback outlast the
call to ctf_link_add_strtab or ctf_link_shuffle_syms.
Right now, the duplicate elimination mechanism is the one already
present as part of the ctf_add_type function, and is not particularly
good: it misses numerous actual duplicates, and the conflicting-types
detection hardly ever reports that types conflict, even when they do
(one of them just tends to get silently dropped): it is also very slow.
This will all be fixed in the next few weeks, but the fix hardly touches
any of this code, and the linker does work without it, just not as
well as it otherwise might. (And when no CTF section is present,
there is no effect on performance, of course. So only people using
a trunk GCC with not-yet-committed patches will even notice. By the
time it gets upstream, things should be better.)
v3: Fix error handling.
v4: check for strdup failure.
v5: fix tabdamage.
include/
* ctf-api.h (struct ctf_link_sym): New, a symbol in flight to the
libctf linking machinery.
(CTF_LINK_SHARE_UNCONFLICTED): New.
(CTF_LINK_SHARE_DUPLICATED): New.
(ECTF_LINKADDEDLATE): New, replacing ECTF_UNUSED.
(ECTF_NOTYET): New, a 'not yet implemented' message.
(ctf_link_add_ctf): New, add an input file's CTF to the link.
(ctf_link): New, merge the type and string sections.
(ctf_link_strtab_string_f): New, callback for feeding strtab info.
(ctf_link_iter_symbol_f): New, callback for feeding symtab info.
(ctf_link_add_strtab): New, tell the CTF linker about the ELF
strtab's strings.
(ctf_link_shuffle_syms): New, ask the CTF linker to shuffle its
symbols into symtab order.
(ctf_link_write): New, ask the CTF linker to write the CTF out.
libctf/
* ctf-link.c: New file, linking of the string and type sections.
* Makefile.am (libctf_a_SOURCES): Add it.
* Makefile.in: Regenerate.
* ctf-impl.h (ctf_file_t): New fields ctf_link_inputs,
ctf_link_outputs.
* ctf-create.c (ctf_update): Update accordingly.
* ctf-open.c (ctf_file_close): Likewise.
* ctf-error.c (_ctf_errlist): Updated with new errors.
Diffstat (limited to 'libctf/Makefile.in')
-rw-r--r-- | libctf/Makefile.in | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/libctf/Makefile.in b/libctf/Makefile.in index c898eb4..1d2efb9 100644 --- a/libctf/Makefile.in +++ b/libctf/Makefile.in @@ -131,16 +131,16 @@ am__v_AR_1 = libctf_a_AR = $(AR) $(ARFLAGS) libctf_a_LIBADD = am__libctf_a_SOURCES_DIST = ctf-archive.c ctf-dump.c ctf-create.c \ - ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-lookup.c \ - ctf-open.c ctf-open-bfd.c ctf-string.c ctf-subr.c ctf-types.c \ - ctf-util.c ctf-qsort_r.c + ctf-decl.c ctf-error.c ctf-hash.c ctf-labels.c ctf-link.c \ + ctf-lookup.c ctf-open.c ctf-open-bfd.c ctf-string.c ctf-subr.c \ + ctf-types.c ctf-util.c ctf-qsort_r.c @NEED_CTF_QSORT_R_TRUE@am__objects_1 = ctf-qsort_r.$(OBJEXT) am_libctf_a_OBJECTS = ctf-archive.$(OBJEXT) ctf-dump.$(OBJEXT) \ ctf-create.$(OBJEXT) ctf-decl.$(OBJEXT) ctf-error.$(OBJEXT) \ - ctf-hash.$(OBJEXT) ctf-labels.$(OBJEXT) ctf-lookup.$(OBJEXT) \ - ctf-open.$(OBJEXT) ctf-open-bfd.$(OBJEXT) ctf-string.$(OBJEXT) \ - ctf-subr.$(OBJEXT) ctf-types.$(OBJEXT) ctf-util.$(OBJEXT) \ - $(am__objects_1) + ctf-hash.$(OBJEXT) ctf-labels.$(OBJEXT) ctf-link.$(OBJEXT) \ + ctf-lookup.$(OBJEXT) ctf-open.$(OBJEXT) ctf-open-bfd.$(OBJEXT) \ + ctf-string.$(OBJEXT) ctf-subr.$(OBJEXT) ctf-types.$(OBJEXT) \ + ctf-util.$(OBJEXT) $(am__objects_1) libctf_a_OBJECTS = $(am_libctf_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -331,9 +331,9 @@ AM_CPPFLAGS = -D_GNU_SOURCE -I$(top_srcdir) -I$(top_srcdir)/../include -I$(top_s AM_CFLAGS = -std=gnu99 @ac_libctf_warn_cflags@ @warn@ @c_warn@ @WARN_PEDANTIC@ @WERROR@ $(ZLIBINC) noinst_LIBRARIES = libctf.a libctf_a_SOURCES = ctf-archive.c ctf-dump.c ctf-create.c ctf-decl.c \ - ctf-error.c ctf-hash.c ctf-labels.c ctf-lookup.c ctf-open.c \ - ctf-open-bfd.c ctf-string.c ctf-subr.c ctf-types.c ctf-util.c \ - $(am__append_1) + ctf-error.c ctf-hash.c ctf-labels.c ctf-link.c ctf-lookup.c \ + ctf-open.c ctf-open-bfd.c ctf-string.c ctf-subr.c ctf-types.c \ + ctf-util.c $(am__append_1) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -409,6 +409,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-hash.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-labels.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-link.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-lookup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-open-bfd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctf-open.Po@am__quote@ |