2021-02-04 02:42:06 +08:00
|
|
|
|
2021-02-02 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* configure.ac (CTF_LIBADD): Remove explicit -lintl population in
|
|
|
|
|
favour of LIBINTL.
|
|
|
|
|
* Makefile.am (libctf_nobfd_la_LIBADD): No longer explicitly
|
|
|
|
|
include $(LIBINTL).
|
|
|
|
|
(check-DEJAGNU): Pass down to tests as well.
|
|
|
|
|
* configure: Regenerated.
|
|
|
|
|
* Makefile.in: Likewise.
|
|
|
|
|
|
libctf: always name nameless types "", never NULL
The ctf_type_name_raw and ctf_type_aname_raw functions, which return the
raw, unadorned name of CTF types, have one unfortunate wrinkle: they
return NULL not only on error but when returning the name of types
without a name in writable dicts. This was unintended: it not only
makes it impossible to reliably tell if a given call to
ctf_type_name_raw failed (due to a bad string offset say), but also
complicates all its callers, who now have to check for both NULL and "".
The written-out form of CTF has no concept of a NULL pointer instead of
a string: all null strings are strtab offset 0, "". So the more we can
do to remove this distinction from the writable form, the less complex
the rest of our code needs to be.
Armour against NULL in multiple places, arranging to return "" from
ctf_type_name_raw if offset 0 is passed in, and removing a risky
optimization from ctf_str_add* that avoided doing anything if a NULL was
passed in: this added needless irregularity to the functions' API
surface, since "" and NULL should be treated identically, and in the
case of ctf_str_add_ref, we shouldn't skip adding the passed-in REF to
the list of references to be updated no matter what the content of the
string happens to be.
This means we can simplify the deduplicator a tiny bit, also fixing a
bug (latent when used by ld) where if the input dict was writable,
we failed to realise when types were nameless and could end up creating
deeply unhelpful synthetic forwards with no name, which we just banned
a few commits ago, so the link failed.
libctf/ChangeLog
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-string.c (ctf_str_add): Treat adding a NULL as adding "".
(ctf_str_add_ref): Likewise.
(ctf_str_add_external): Likewise.
* ctf-types.c (ctf_type_name_raw): Always return "" for offset 0.
* ctf-dedup.c (ctf_dedup_multiple_input_dicts): Don't armour
against NULL name.
(ctf_dedup_maybe_synthesize_forward): Likewise.
2021-01-29 21:33:11 +08:00
|
|
|
|
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-string.c (ctf_str_add): Treat adding a NULL as adding "".
|
|
|
|
|
(ctf_str_add_ref): Likewise.
|
|
|
|
|
(ctf_str_add_external): Likewise.
|
|
|
|
|
* ctf-types.c (ctf_type_name_raw): Always return "" for offset 0.
|
|
|
|
|
* ctf-dedup.c (ctf_dedup_multiple_input_dicts): Don't armour
|
|
|
|
|
against NULL name.
|
|
|
|
|
(ctf_dedup_maybe_synthesize_forward): Likewise.
|
|
|
|
|
|
2021-01-28 23:00:11 +08:00
|
|
|
|
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-create.c (ctf_serialize): Fix shadowing.
|
|
|
|
|
|
2021-01-28 03:55:45 +08:00
|
|
|
|
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-create.c (ctf_add_encoded): Add check for non-empty name.
|
|
|
|
|
(ctf_add_forward): Likewise.
|
|
|
|
|
(ctf_add_typedef): Likewise.
|
|
|
|
|
|
2021-01-28 03:41:49 +08:00
|
|
|
|
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-open.c (init_types): Rip out code to check anonymous typedef
|
|
|
|
|
nodes.
|
|
|
|
|
* ctf-create.c (ctf_add_reftype): Likewise.
|
|
|
|
|
* ctf-lookup.c (refresh_pptrtab): Likewise.
|
|
|
|
|
|
libctf, ld: fix symtypetab and var section population under ld -r
The variable section in a CTF dict is meant to contain the types of
variables that do not appear in the symbol table (mostly file-scope
static declarations). We implement this by having the compiler emit
all potential data symbols into both sections, then delete those
symbols from the variable section that correspond to data symbols the
linker has reported.
Unfortunately, the check for this in ctf_serialize is wrong: rather than
checking the set of linker-reported symbols, we check the set of names
in the data object symtypetab section: if the linker has reported no
symbols at all (usually if ld -r has been run, or if a non-linker
program that does not use symbol tables is calling ctf_link) this will
include every single symbol, emptying the variable section completely.
Worse, when ld -r is in use, we want to force writeout of every
symtypetab entry on the inputs, in an indexed section, whether or not
the linker has reported them, since this isn't a final link yet and the
symbol table is not finalized (and may grow more symbols than the linker
has yet reported). But the check for this is flawed too: we were
relying on ctf_link_shuffle_syms not having been called if no symbols
exist, but that function is *always* called by ld even when ld -r is in
use: ctf_link_add_linker_symbol is the one that's not called when there
are no symbols.
We clearly need to rethink this. Using the emptiness of the set of
reported symbols as a test for ld -r is just ugly: the linker already
knows if ld -r is underway and can just tell us. So add a new linker
flag CTF_LINK_NO_FILTER_REPORTED_SYMS that is set to stop the linker
filtering the symbols in the symtypetab sections using the set that the
linker has reported: use the presence or absence of this flag to
determine whether to emit unindexed symtabs: we only remove entries from
the variable section when filtering symbols, and we only remove them if
they are in the reported symbol set, fixing the case where no symbols
are reported by the linker at all.
(The negative sense of the new CTF_LINK flag is intentional: the common
case, both for ld and for simple tools that want to do a ctf_link with
no ELF symbol table in sight, is probably to filter out symbols that no
linker has reported: i.e., for the simple tools, all of them.)
There's another wrinkle, though. It is quite possible for a non-linker
to add symbols to a dict via ctf_add_*_sym and then write it out via the
ctf_write APIs: perhaps it's preparing a dict for a later linker
invocation. Right now this would not lead to anything terribly
meaningful happening: ctf_serialize just assumes it was called via
ctf_link if symbols are present. So add an (internal-to-libctf) flag
that indicates that a writeout is happening via ctf_link_write, and set
it there (propagating it to child dicts as needed). ctf_serialize can
then spot when it is not being called by a linker, and arrange to always
write out an indexed, sorted symtypetab for fastest possible future
symbol lookup by name in that case. (The writeouts done by ld -r are
unsorted, because the only thing likely to use those symtabs is the
linker, which doesn't benefit from symtypetab sorting.)
Tests added for all three linking cases (ld -r, ld -shared, ld), with a
bit of testsuite framework enhancement to stop it unconditionally
linking the CTF to be checked by the lookup program with -shared, so
tests can now examine CTF linked with -r or indeed with no flags at all,
though the output filename is still foo.so even in this case.
Another test added for the non-linker case that endeavours to determine
whether the symtypetab is sorted by examining the order of entries
returned from ctf_symbol_next: nobody outside libctf should rely on
this ordering, but this test is not outside libctf :)
include/ChangeLog
2021-01-26 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (CTF_LINK_NO_FILTER_REPORTED_SYMS): New.
ld/ChangeLog
2021-01-26 Nick Alcock <nick.alcock@oracle.com>
* ldlang.c (lang_merge_ctf): Set CTF_LINK_NO_FILTER_REPORTED_SYMS
when appropriate.
libctf/ChangeLog
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-impl.c (_libctf_nonnull_): Add parameters.
(LCTF_LINKING): New flag.
(ctf_dict_t) <ctf_link_flags>: Mention it.
* ctf-link.c (ctf_link): Keep LCTF_LINKING set across call.
(ctf_write): Likewise, including in child dictionaries.
(ctf_link_shuffle_syms): Make sure ctf_dynsyms is NULL if there
are no reported symbols.
* ctf-create.c (symtypetab_delete_nonstatic_vars): Make sure
the variable has been reported as a symbol by the linker.
(symtypetab_skippable): Mention relationship between SYMFP and the
flags.
(symtypetab_density): Adjust nonnullity. Exit early if no symbols
were reported and force-indexing is off (i.e., we are doing a
final link).
(ctf_serialize): Handle the !LCTF_LINKING case by writing out an
indexed, sorted symtypetab (and allow SYMFP to be NULL in this
case). Turn sorting off if this is a non-final link. Only delete
nonstatic vars if we are filtering symbols and the linker has
reported some.
* testsuite/libctf-regression/nonstatic-var-section-ld-r*:
New test of variable and symtypetab section population when
ld -r is used.
* testsuite/libctf-regression/nonstatic-var-section-ld-executable.lk:
Likewise, when ld of an executable is used.
* testsuite/libctf-regression/nonstatic-var-section-ld.lk:
Likewise, when ld -shared alone is used.
* testsuite/libctf-regression/nonstatic-var-section-ld*.c:
Lookup programs for the above.
* testsuite/libctf-writable/symtypetab-nonlinker-writeout.*: New
test, testing survival of symbols across ctf_write paths.
* testsuite/lib/ctf-lib.exp (run_lookup_test): New option,
nonshared, suppressing linking of the SOURCE with -shared.
2021-01-17 00:49:29 +08:00
|
|
|
|
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-impl.c (_libctf_nonnull_): Add parameters.
|
|
|
|
|
(LCTF_LINKING): New flag.
|
|
|
|
|
(ctf_dict_t) <ctf_link_flags>: Mention it.
|
|
|
|
|
* ctf-link.c (ctf_link): Keep LCTF_LINKING set across call.
|
|
|
|
|
(ctf_write): Likewise, including in child dictionaries.
|
|
|
|
|
(ctf_link_shuffle_syms): Make sure ctf_dynsyms is NULL if there
|
|
|
|
|
are no reported symbols.
|
|
|
|
|
* ctf-create.c (symtypetab_delete_nonstatic_vars): Make sure
|
|
|
|
|
the variable has been reported as a symbol by the linker.
|
|
|
|
|
(symtypetab_skippable): Mention relationship between SYMFP and the
|
|
|
|
|
flags.
|
|
|
|
|
(symtypetab_density): Adjust nonnullity. Exit early if no symbols
|
|
|
|
|
were reported and force-indexing is off (i.e., we are doing a
|
|
|
|
|
final link).
|
|
|
|
|
(ctf_serialize): Handle the !LCTF_LINKING case by writing out an
|
|
|
|
|
indexed, sorted symtypetab (and allow SYMFP to be NULL in this
|
|
|
|
|
case). Turn sorting off if this is a non-final link. Only delete
|
|
|
|
|
nonstatic vars if we are filtering symbols and the linker has
|
|
|
|
|
reported some.
|
|
|
|
|
* testsuite/libctf-regression/nonstatic-var-section-ld-r*:
|
|
|
|
|
New test of variable and symtypetab section population when
|
|
|
|
|
ld -r is used.
|
|
|
|
|
* testsuite/libctf-regression/nonstatic-var-section-ld-executable.lk:
|
|
|
|
|
Likewise, when ld of an executable is used.
|
|
|
|
|
* testsuite/libctf-regression/nonstatic-var-section-ld.lk:
|
|
|
|
|
Likewise, when ld -shared alone is used.
|
|
|
|
|
* testsuite/libctf-regression/nonstatic-var-section-ld*.c:
|
|
|
|
|
Lookup programs for the above.
|
|
|
|
|
* testsuite/libctf-writable/symtypetab-nonlinker-writeout.*: New
|
|
|
|
|
test, testing survival of symbols across ctf_write paths.
|
|
|
|
|
* testsuite/lib/ctf-lib.exp (run_lookup_test): New option,
|
|
|
|
|
nonshared, suppressing linking of the SOURCE with -shared.
|
|
|
|
|
|
2021-01-19 20:45:18 +08:00
|
|
|
|
2021-01-19 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-create.c (membadd): Transform ""-named members into
|
|
|
|
|
NULL-named ones.
|
|
|
|
|
* testsuite/libctf-regression/type-add-unnamed-struct*: New test.
|
|
|
|
|
|
2021-01-19 20:45:18 +08:00
|
|
|
|
2021-01-19 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-lookup.c (ctf_lookup_by_name_internal): Do not return the
|
|
|
|
|
base type if looking up a nonexistent pointer type.
|
|
|
|
|
* testsuite/libctf-regression/pptrtab*: Test it.
|
|
|
|
|
|
2021-01-13 16:43:23 +08:00
|
|
|
|
2021-01-13 Alan Modra <amodra@gmail.com>
|
|
|
|
|
|
|
|
|
|
* Makefile.in: Regenerate.
|
|
|
|
|
|
2021-01-12 21:45:28 +08:00
|
|
|
|
2021-01-12 H.J. Lu <hongjiu.lu@intel.com>
|
|
|
|
|
|
|
|
|
|
PR binutils/26792
|
|
|
|
|
* configure.ac: Use GNU_MAKE_JOBSERVER.
|
|
|
|
|
* aclocal.m4: Regenerated.
|
|
|
|
|
* configure: Likewise.
|
|
|
|
|
|
2021-01-12 08:29:31 +08:00
|
|
|
|
2021-01-11 H.J. Lu <hongjiu.lu@intel.com>
|
|
|
|
|
|
|
|
|
|
PR ld/27173
|
|
|
|
|
* configure: Regenerated.
|
|
|
|
|
|
2021-01-09 22:47:58 +08:00
|
|
|
|
2021-01-09 H.J. Lu <hongjiu.lu@intel.com>
|
|
|
|
|
|
|
|
|
|
* configure: Regenerated.
|
|
|
|
|
|
2021-01-09 18:40:28 +08:00
|
|
|
|
2021-01-09 Nick Clifton <nickc@redhat.com>
|
|
|
|
|
|
|
|
|
|
* 2.36 release branch crated.
|
|
|
|
|
|
2021-01-09 08:33:29 +08:00
|
|
|
|
2021-01-09 Alan Modra <amodra@gmail.com>
|
|
|
|
|
|
|
|
|
|
* configure: Regenerate.
|
|
|
|
|
|
2021-01-08 00:47:36 +08:00
|
|
|
|
2021-01-07 Samuel Thibault <samuel.thibault@gnu.org>
|
|
|
|
|
|
|
|
|
|
* configure: Regenerate.
|
|
|
|
|
|
2021-01-06 03:34:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* testsuite/libctf-lookup/struct-iteration.c (main):
|
|
|
|
|
ctf_member_count returns an int.
|
|
|
|
|
|
2021-01-06 01:11:20 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* Makefile.am (BASEDIR): New.
|
|
|
|
|
(BFDDIR): Likewise.
|
|
|
|
|
(check-DEJAGNU): Add development.exp to prerequisites.
|
|
|
|
|
(development.exp): New.
|
|
|
|
|
(CONFIG_STATUS_DEPENDENCIES): New.
|
|
|
|
|
(EXTRA_DEJAGNU_SITE_CONFIG): Likewise.
|
|
|
|
|
(DISTCLEANFILES): Likewise.
|
|
|
|
|
* Makefile.in: Regenerated.
|
|
|
|
|
* testsuite/lib/ctf-lib.exp (check_ctf_available): Return boolean.
|
|
|
|
|
* testsuite/libctf-lookup/lookup.exp: Call check_ctf_available.
|
|
|
|
|
* testsuite/libctf-regression/regression.exp: Likewise.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-types.c (ctf_type_aname): Print forwards to unions and enums
|
|
|
|
|
properly.
|
|
|
|
|
|
libctf: fix lookups of pointers by name in parent dicts
When you look up a type by name using ctf_lookup_by_name, in most cases
libctf can just strip off any qualifiers and look for the name, but for
pointer types this doesn't work, since the caller will want the pointer
type itself. But pointer types are nameless, and while they cite the
types they point to, looking up a type by name requires a link going the
*other way*, from the type pointed to to the pointer type that points to
it.
libctf has always built this up at open time: ctf_ptrtab is an array of
type indexes pointing from the index of every type to the index of the
type that points to it. But because it is built up at open time (and
because it uses type indexes and not type IDs) it is restricted to
working within a single dict and ignoring parent/child
relationships. This is normally invisible, unless you manage to get a
dict with a type in the parent but the only pointer to it in a child.
The ctf_ptrtab will not track this relationship, so lookups of this
pointer type by name will fail. Since which type is in the parent and
which in the child is largely opaque to the user (which goes where is up
to the deduplicator, and it can and does reshuffle things to save
space), this leads to a very bad user experience, with an
obviously-visible pointer type which ctf_lookup_by_name claims doesn't
exist.
The fix is to have another array, ctf_pptrtab, which is populated in
child dicts: like the parent's ctf_ptrtab, it has one element per type
in the parent, but is all zeroes except for those types which are
pointed to by types in the child: so it maps parent dict indices to
child dict indices. The array is grown, and new child types scanned,
whenever a lookup happens and new types have been added to the child
since the last time a lookup happened that might need the pptrtab.
(So for non-writable dicts, this only happens once, since new types
cannot be added to non-writable dicts at all.)
Since this introduces new complexity (involving updating only part of
the ctf_pptrtab) which is only seen when a writable dict is in use, we
introduce a new libctf-writable testsuite that contains lookup tests
with no corresponding CTF-containing .c files (which can thus be run
even on platforms with no .ctf-section support in the linker yet), and
add a test to check that creation of pointers in children to types in
parents and a following lookup by name works as expected. The non-
writable case is tested in a new libctf-regression testsuite which is
used to track now-fixed outright bugs in libctf.
libctf/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-impl.h (ctf_dict_t) <ctf_pptrtab>: New.
<ctf_pptrtab_len>: New.
<ctf_pptrtab_typemax>: New.
* ctf-create.c (ctf_serialize): Update accordingly.
(ctf_add_reftype): Note that we don't need to update pptrtab here,
despite updating ptrtab.
* ctf-open.c (ctf_dict_close): Destroy the pptrtab.
(ctf_import): Likewise.
(ctf_import_unref): Likewise.
* ctf-lookup.c (grow_pptrtab): New.
(refresh_pptrtab): New, update a pptrtab.
(ctf_lookup_by_name): Turn into a wrapper around (and rename to)...
(ctf_lookup_by_name_internal): ... this: construct the pptrtab, and
use it in addition to the parent's ptrtab when parent dicts are
searched.
* testsuite/libctf-regression/regression.exp: New testsuite for
regression tests.
* testsuite/libctf-regression/pptrtab*: New test.
* testsuite/libctf-writable/writable.exp: New testsuite for tests of
writable CTF dicts.
* testsuite/libctf-writable/pptrtab*: New test.
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-impl.h (ctf_dict_t) <ctf_pptrtab>: New.
|
|
|
|
|
<ctf_pptrtab_len>: New.
|
|
|
|
|
<ctf_pptrtab_typemax>: New.
|
|
|
|
|
* ctf-create.c (ctf_serialize): Update accordingly.
|
|
|
|
|
(ctf_add_reftype): Note that we don't need to update pptrtab here,
|
|
|
|
|
despite updating ptrtab.
|
|
|
|
|
* ctf-open.c (ctf_dict_close): Destroy the pptrtab.
|
|
|
|
|
(ctf_import): Likewise.
|
|
|
|
|
(ctf_import_unref): Likewise.
|
|
|
|
|
* ctf-lookup.c (grow_pptrtab): New.
|
|
|
|
|
(refresh_pptrtab): New, update a pptrtab.
|
|
|
|
|
(ctf_lookup_by_name): Turn into a wrapper around (and rename to)...
|
|
|
|
|
(ctf_lookup_by_name_internal): ... this: construct the pptrtab, and
|
|
|
|
|
use it in addition to the parent's ptrtab when parent dicts are
|
|
|
|
|
searched.
|
|
|
|
|
* testsuite/libctf-regression/regression.exp: New testsuite for
|
|
|
|
|
regression tests.
|
|
|
|
|
* testsuite/libctf-regression/pptrtab*: New test.
|
|
|
|
|
* testsuite/libctf-writable/writable.exp: New testsuite for tests of
|
|
|
|
|
writable CTF dicts.
|
|
|
|
|
* testsuite/libctf-writable/pptrtab*: New test.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-archive.c (ctf_archive_iter): Remove outdated comment.
|
|
|
|
|
|
libctf, include: support unnamed structure members better
libctf has no intrinsic support for the GCC unnamed structure member
extension. This principally means that you can't look up named members
inside unnamed struct or union members via ctf_member_info: you have to
tiresomely find out the type ID of the unnamed members via iteration,
then look in each of these.
This is ridiculous. Fix it by extending ctf_member_info so that it
recurses into unnamed members for you: this is still unambiguous because
GCC won't let you create ambiguously-named members even in the presence
of this extension.
For consistency, and because the release hasn't happened and we can
still do this, break the ctf_member_next API and add flags: we specify
one flag, CTF_MN_RECURSE, which if set causes ctf_member_next to
automatically recurse into unnamed members for you, returning not only
the members themselves but all their contained members, so that you can
use ctf_member_next to identify every member that it would be valid to
call ctf_member_info with.
New lookup tests are added for all of this.
include/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (CTF_MN_RECURSE): New.
(ctf_member_next): Add flags argument.
libctf/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-impl.h (struct ctf_next) <u.ctn_next>: Move to...
<ctn_next>: ... here.
* ctf-util.c (ctf_next_destroy): Unconditionally destroy it.
* ctf-lookup.c (ctf_symbol_next): Adjust accordingly.
* ctf-types.c (ctf_member_iter): Reimplement in terms of...
(ctf_member_next): ... this. Support recursive unnamed member
iteration (off by default).
(ctf_member_info): Look up members in unnamed sub-structs.
* ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_member_next call.
(ctf_dedup_emit_struct_members): Likewise.
* testsuite/libctf-lookup/struct-iteration-ctf.c: Test empty unnamed
members, and a normal member after the end.
* testsuite/libctf-lookup/struct-iteration.c: Verify that
ctf_member_count is consistent with the number of successful returns
from a non-recursive ctf_member_next.
* testsuite/libctf-lookup/struct-iteration-*: New, test iteration
over struct members.
* testsuite/libctf-lookup/struct-lookup.c: New test.
* testsuite/libctf-lookup/struct-lookup.lk: New test.
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-impl.h (struct ctf_next) <u.ctn_next>: Move to...
|
|
|
|
|
<ctn_next>: ... here.
|
|
|
|
|
* ctf-util.c (ctf_next_destroy): Unconditionally destroy it.
|
|
|
|
|
* ctf-lookup.c (ctf_symbol_next): Adjust accordingly.
|
|
|
|
|
* ctf-types.c (ctf_member_iter): Reimplement in terms of...
|
|
|
|
|
(ctf_member_next): ... this. Support recursive unnamed member
|
|
|
|
|
iteration (off by default).
|
|
|
|
|
(ctf_member_info): Look up members in unnamed sub-structs.
|
|
|
|
|
* ctf-dedup.c (ctf_dedup_rhash_type): Adjust ctf_member_next call.
|
|
|
|
|
(ctf_dedup_emit_struct_members): Likewise.
|
|
|
|
|
* testsuite/libctf-lookup/struct-iteration-ctf.c: Test empty unnamed
|
|
|
|
|
members, and a normal member after the end.
|
|
|
|
|
* testsuite/libctf-lookup/struct-iteration.c: Verify that
|
|
|
|
|
ctf_member_count is consistent with the number of successful returns
|
|
|
|
|
from a non-recursive ctf_member_next.
|
|
|
|
|
* testsuite/libctf-lookup/struct-iteration-*: New, test iteration
|
|
|
|
|
over struct members.
|
|
|
|
|
* testsuite/libctf-lookup/struct-lookup.c: New test.
|
|
|
|
|
* testsuite/libctf-lookup/struct-lookup.lk: New test.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-link.c (ctf_link_warn_outdated_inputs): New.
|
|
|
|
|
(ctf_link_write): Call it.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* testsuite/libctf-lookup/enum-symbol.lk: New symbol-lookup test.
|
|
|
|
|
* testsuite/libctf-lookup/enum-symbol-ctf.c: New CTF input.
|
|
|
|
|
* testsuite/libctf-lookup/enum-symbol.c: New lookup test.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* Makefile.am (EXPECT): New.
|
|
|
|
|
(RUNTEST): Likewise.
|
|
|
|
|
(RUNTESTFLAGS): Likewise.
|
|
|
|
|
(CC_FOR_TARGET): Likewise.
|
|
|
|
|
(check-DEJAGNU): Likewise.
|
|
|
|
|
(AUTOMAKE_OPTIONS): Add dejagnu.
|
|
|
|
|
* Makefile.in: Regenerated.
|
|
|
|
|
* testsuite/config/default.exp: New.
|
|
|
|
|
* testsuite/lib/ctf-lib.exp: Likewise.
|
|
|
|
|
* testsuite/libctf-lookup/enum.lk: New test.
|
|
|
|
|
* testsuite/libctf-lookup/enum-ctf.c: New CTF input.
|
|
|
|
|
* testsuite/libctf-lookup/enum.c: New lookup test.
|
|
|
|
|
* testsuite/libctf-lookup/ambiguous-struct*.c: New test.
|
|
|
|
|
* testsuite/libctf-lookup/lookup.exp: New.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* configure.ac (BFD_LIBADD): Remove.
|
|
|
|
|
(BFD_DEPENDENCIES): Likewise. Remove associated cases.
|
|
|
|
|
(SHARED_LIBADD): Rename to...
|
|
|
|
|
(CTF_LIBADD): ... this. Stick in a suitable libiberty even when
|
|
|
|
|
linking statically.
|
|
|
|
|
* Makefile.am (libctf_nobfd_la_LIBADD): Adjust accordingly.
|
|
|
|
|
libctf uses libintl.
|
|
|
|
|
(libctf_la_LIBADD): Reference libbfd.la directly, not via
|
|
|
|
|
BFD_LIBADD.
|
|
|
|
|
(libctf_la_DEPENDENCIES): Remove.
|
|
|
|
|
* Makefile.in: Regenerate.
|
|
|
|
|
* configure: Likewise.
|
|
|
|
|
|
libctf, ld: dump enums: generally improve dump formatting
This commit adds dumping of enumerands in this general form:
0x3: (kind 8) enum eleven_els (size 0x4) (aligned at 0x4)
ELEVEN_ONE: 10
ELEVEN_TWO: 11
ELEVEN_THREE: -256
ELEVEN_FOUR: -255
ELEVEN_FIVE: -254
...
ELEVEN_SEVEN: -252
ELEVEN_EIGHT: -251
ELEVEN_NINE: -250
ELEVEN_TEN: -249
ELEVEN_ELEVEN: -248
The first and last enumerands in the enumerated type are printed so that
you can tell if they've been cut off at one end or the other. (For now,
there is no way to control how many enumerands are printed.)
The dump output in general is improved, from this sort of thing a few
days ago:
4c: char [0x0:0x8] (size 0x1)
[0x0] (ID 0x4c) (kind 1) char:8 (aligned at 0x1, format 0x3, offset:bits 0x0:0x8)
4d: char * (size 0x8) -> 4c: char [0x0:0x8] (size 0x1)
[0x0] (ID 0x4d) (kind 3) char * (aligned at 0x8)
[...]
5a: struct _IO_FILE (size 0xd8)
[0x0] (ID 0x5a) (kind 6) struct _IO_FILE (aligned at 0x4)
[0x0] (ID 0x3) (kind 1) int _flags:32 (aligned at 0x4, format 0x1, offset:bits 0x0:0x20)
[0x40] (ID 0x4d) (kind 3) char * _IO_read_ptr (aligned at 0x8)
[0x80] (ID 0x4d) (kind 3) char * _IO_read_end (aligned at 0x8)
[0xc0] (ID 0x4d) (kind 3) char * _IO_read_base (aligned at 0x8)
5b: __FILE (size 0xd8) -> 5a: struct _IO_FILE (size 0xd8)
[0x0] (ID 0x5b) (kind 10) __FILE (aligned at 0x4)
[0x0] (ID 0x3) (kind 1) int _flags:32 (aligned at 0x4, format 0x1, offset:bits 0x0:0x20)
[0x40] (ID 0x4d) (kind 3) char * _IO_read_ptr (aligned at 0x8)
[0x80] (ID 0x4d) (kind 3) char * _IO_read_end (aligned at 0x8)
[0xc0] (ID 0x4d) (kind 3) char * _IO_read_base (aligned at 0x8)
[...]
406: struct coff_link_hash_entry (size 0x60)
[0x0] (ID 0x406) (kind 6) struct coff_link_hash_entry (aligned at 0x8)
[0x0] (ID 0x2b3) (kind 6) struct bfd_link_hash_entry root (aligned at 0x8)
[0x0] (ID 0x1d6) (kind 6) struct bfd_hash_entry root (aligned at 0x8)
[0x0] (ID 0x1d7) (kind 3) struct bfd_hash_entry * next (aligned at 0x8)
[0x40] (ID 0x61) (kind 3) const char * string (aligned at 0x8)
[0x80] (ID 0x1) (kind 1) long unsigned int hash:64 (aligned at 0x8, format 0x0, offset:bits 0x0:0x40)
[0xc0] (ID 0x397) (kind 8) enum bfd_link_hash_type type:8 (aligned at 0x1, format 0x0, offset:bits 0x0:0x8)
[0xc8] (ID 0x1c7) (kind 1) unsigned int non_ir_ref_regular:1 (aligned at 0x1, format 0x0, offset:bits 0x8:0x1)
[0xc9] (ID 0x1c8) (kind 1) unsigned int non_ir_ref_dynamic:1 (aligned at 0x1, format 0x0, offset:bits 0x9:0x1)
[0xca] (ID 0x1c9) (kind 1) unsigned int linker_def:1 (aligned at 0x1, format 0x0, offset:bits 0xa:0x1)
[0xcb] (ID 0x1ca) (kind 1) unsigned int ldscript_def:1 (aligned at 0x1, format 0x0, offset:bits 0xb:0x1)
[0xcc] (ID 0x1cb) (kind 1) unsigned int rel_from_abs:1 (aligned at 0x1, format 0x0, offset:bits 0xc:0x1)
... to this:
0x4c: (kind 1) char (format 0x3) (size 0x1) (aligned at 0x1)
0x4d: (kind 3) char * (size 0x8) (aligned at 0x8) -> 0x4c: (kind 1) char (format 0x3) (size 0x1) (aligned at 0x1)
0x5a: (kind 6) struct _IO_FILE (size 0xd8) (aligned at 0x4)
[0x0] _flags: ID 0x3: (kind 1) int (format 0x1) (size 0x4) (aligned at 0x4)
[0x40] _IO_read_ptr: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
[0x80] _IO_read_end: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
[0xc0] _IO_read_base: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
[0x100] _IO_write_base: ID 0x4d: (kind 3) char * (size 0x8) (aligned at 0x8)
0x5b: (kind 10) __FILE (size 0xd8) (aligned at 0x4) -> 0x5a: (kind 6) struct _IO_FILE (size 0xd8) (aligned at 0x4)
[...]
0x406: (kind 6) struct coff_link_hash_entry (size 0x60) (aligned at 0x8)
[0x0] root: ID 0x2b3: (kind 6) struct bfd_link_hash_entry (size 0x38) (aligned at 0x8)
[0x0] root: ID 0x1d6: (kind 6) struct bfd_hash_entry (size 0x18) (aligned at 0x8)
[0x0] next: ID 0x1d7: (kind 3) struct bfd_hash_entry * (size 0x8) (aligned at 0x8)
[0x40] string: ID 0x61: (kind 3) const char * (size 0x8) (aligned at 0x8)
[0x80] hash: ID 0x1: (kind 1) long unsigned int (format 0x0) (size 0x8) (aligned at 0x8)
[0xc0] type: ID 0x397: (kind 8) enum bfd_link_hash_type (format 0x7f2e) (size 0x1) (aligned at 0x1)
[0xc8] non_ir_ref_regular: ID 0x1c7: (kind 1) unsigned int:1 [slice 0x8:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[0xc9] non_ir_ref_dynamic: ID 0x1c8: (kind 1) unsigned int:1 [slice 0x9:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[0xca] linker_def: ID 0x1c9: (kind 1) unsigned int:1 [slice 0xa:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[0xcb] ldscript_def: ID 0x1ca: (kind 1) unsigned int:1 [slice 0xb:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[0xcc] rel_from_abs: ID 0x1cb: (kind 1) unsigned int:1 [slice 0xc:0x1] (format 0x0) (size 0x1) (aligned at 0x1)
[...]
In particular, indented subsections are only present for actual structs
and unions, not forwards to them, and the structure itself doesn't add a
spurious level of indentation; structure field names are easier to spot
(at the cost of not making them look so much like C field declarations
any more, but they weren't always shown in valid decl syntax even before
this change) the size, type kind, and alignment are shown for all types
for which they are meaningful; bitfield info is only shown for actual
bitfields within structures and not ordinary integral fields; and type
IDs are never omitted. Type printing is in general much more consistent
and there is much less duplicated code in the type dumper.
There is one user-visible effect outside the dumper: ctf_type_(a)name
was erroneously emitting a trailing space on the name of slice types,
even though a slice of an int and an int with the corresponding encoding
represent the same type and should have the same print form. This
trailing space is now gone.
ld/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* testsuite/ld-ctf/array.d: Adjust for dumper changes.
* testsuite/ld-ctf/conflicting-cycle-1.B-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.B-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.A-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-2.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-1.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.C-2.d: Likewise.
* testsuite/ld-ctf/conflicting-cycle-3.parent.d: Likewise.
* testsuite/ld-ctf/conflicting-enums.d: Likewise.
* testsuite/ld-ctf/conflicting-typedefs.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-cyclic-nonconflicting.d: Likewise.
* testsuite/ld-ctf/cross-tu-into-cycle.d: Likewise.
* testsuite/ld-ctf/cross-tu-noncyclic.d: Likewise.
* testsuite/ld-ctf/cycle-1.d: Likewise.
* testsuite/ld-ctf/cycle-2.A.d: Likewise.
* testsuite/ld-ctf/cycle-2.B.d: Likewise.
* testsuite/ld-ctf/cycle-2.C.d: Likewise.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
* testsuite/ld-ctf/diag-cttname-null.d: Likewise.
* testsuite/ld-ctf/diag-cuname.d: Likewise.
* testsuite/ld-ctf/diag-parlabel.d: Likewise.
* testsuite/ld-ctf/diag-wrong-magic-number-mixed.d: Likewise.
* testsuite/ld-ctf/forward.d: Likewise.
* testsuite/ld-ctf/function.d: Likewise.
* testsuite/ld-ctf/slice.d: Likewise.
* testsuite/ld-ctf/super-sub-cycles.d: Likewise.
* testsuite/ld-ctf/enums.c: New test.
* testsuite/ld-ctf/enums.d: New test.
libctf/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-decl.c (ctf_decl_push): Exclude slices from the decl stack.
* ctf-types.c (ctf_type_aname): No longer deal with slices here.
* ctf-dump.c (ctf_dump_membstate_t) <cdm_toplevel_indent>: Constify.
(CTF_FT_REFS): New.
(CTF_FT_BITFIELD): Likewise.
(CTF_FT_ID): Likewise.
(ctf_dump_member): Do not do indentation here. Migrate the
type-printing parts of this into...
(ctf_dump_format_type): ... here, to be shared by all type printers.
Get the errno value for non-representable types right. Do not print
bitfield info for non-bitfields. Improve the format and indentation
of other type output. Shuffle spacing around to make all indentation
either 'width of column' or 4 chars.
(ctf_dump_label): Pass CTF_FT_REFS to ctf_dump_format_type.
(ctf_dump_objts): Likewise. Spacing shuffle.
(ctf_dump_var): Likewise.
(type_hex_digits): Migrate down in the file, to above its new user.
(ctf_dump_type): Indent here instead. Pass CTF_FT_REFS to
ctf_dump_format_type. Don't trim off excess linefeeds now we no
longer generate them. Dump enumerated types.
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-decl.c (ctf_decl_push): Exclude slices from the decl stack.
|
|
|
|
|
* ctf-types.c (ctf_type_aname): No longer deal with slices here.
|
|
|
|
|
* ctf-dump.c (ctf_dump_membstate_t) <cdm_toplevel_indent>: Constify.
|
|
|
|
|
(CTF_FT_REFS): New.
|
|
|
|
|
(CTF_FT_BITFIELD): Likewise.
|
|
|
|
|
(CTF_FT_ID): Likewise.
|
|
|
|
|
(ctf_dump_member): Do not do indentation here. Migrate the
|
|
|
|
|
type-printing parts of this into...
|
|
|
|
|
(ctf_dump_format_type): ... here, to be shared by all type printers.
|
|
|
|
|
Get the errno value for non-representable types right. Do not print
|
|
|
|
|
bitfield info for non-bitfields. Improve the format and indentation
|
|
|
|
|
of other type output. Shuffle spacing around to make all indentation
|
|
|
|
|
either 'width of column' or 4 chars.
|
|
|
|
|
(ctf_dump_label): Pass CTF_FT_REFS to ctf_dump_format_type.
|
|
|
|
|
(ctf_dump_objts): Likewise. Spacing shuffle.
|
|
|
|
|
(ctf_dump_var): Likewise.
|
|
|
|
|
(type_hex_digits): Migrate down in the file, to above its new user.
|
|
|
|
|
(ctf_dump_type): Indent here instead. Pass CTF_FT_REFS to
|
|
|
|
|
ctf_dump_format_type. Don't trim off excess linefeeds now we no
|
|
|
|
|
longer generate them. Dump enumerated types.
|
|
|
|
|
|
libctf, ld: prohibit getting the size or alignment of forwards
C allows you to do only a very few things with entities of incomplete
type (as opposed to pointers to them): make pointers to them and give
them cv-quals, roughly. In particular you can't sizeof them and you
can't get their alignment.
We cannot impose all the requirements the standard imposes on CTF users,
because the deduplicator can transform any structure type into a forward
for the purposes of breaking cycles: so CTF type graphs can easily
contain things like arrays of forward type (if you want to figure out
their size or alignment, you need to chase down the types this forward
might be a forward to in child TU dicts: we will soon add API functions
to make doing this much easier).
Nonetheless, it is still meaningless to ask for the size or alignment of
forwards: but libctf didn't prohibit this and returned nonsense from
internal implementation details when you asked (it returned the kind of
the pointed-to type as both the size and alignment, because forwards
reuse ctt_type as a type kind, and ctt_type and ctt_size overlap). So
introduce a new error, ECTF_INCOMPLETE, which is returned when you try
to get the size or alignment of forwards: we also return it when you try
to do things that require libctf itself to get the size or alignment of
a forward, notably using a forward as an array index type (which C
should never do in any case) or adding forwards to structures without
specifying their offset explicitly.
The dumper will not emit size or alignment info for forwards any more.
(This should not be an API break since ctf_type_size and ctf_type_align
could both return errors before now: any code that isn't expecting error
returns is already potentially broken.)
include/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-api.h (ECTF_INCOMPLETE): New.
(ECTF_NERR): Adjust.
ld/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* testsuite/ld-ctf/conflicting-cycle-1.parent.d: Adjust for dumper
changes.
* testsuite/ld-ctf/cross-tu-cyclic-conflicting.d: Likewise.
* testsuite/ld-ctf/forward.c: New test...
* testsuite/ld-ctf/forward.d: ... and results.
libctf/ChangeLog
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
* ctf-types.c (ctf_type_resolve): Improve comment.
(ctf_type_size): Yield ECTF_INCOMPLETE when applied to forwards.
Emit errors into the right dict.
(ctf_type_align): Likewise.
* ctf-create.c (ctf_add_member_offset): Yield ECTF_INCOMPLETE
when adding a member without explicit offset when this member, or
the previous member, is incomplete.
* ctf-dump.c (ctf_dump_format_type): Do not try to print the size of
forwards.
(ctf_dump_member): Do not try to print their alignment.
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-types.c (ctf_type_resolve): Improve comment.
|
|
|
|
|
(ctf_type_size): Yield ECTF_INCOMPLETE when applied to forwards.
|
|
|
|
|
Emit errors into the right dict.
|
|
|
|
|
(ctf_type_align): Likewise.
|
|
|
|
|
* ctf-create.c (ctf_add_member_offset): Yield ECTF_INCOMPLETE
|
|
|
|
|
when adding a member without explicit offset when this member, or
|
|
|
|
|
the previous member, is incomplete.
|
|
|
|
|
* ctf-dump.c (ctf_dump_format_type): Do not try to print the size of
|
|
|
|
|
forwards.
|
|
|
|
|
(ctf_dump_member): Do not try to print their alignment.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-dump.c (ctf_dump_objts): Dump by calling ctf_dump_format_type.
|
|
|
|
|
(ctf_dump_format_type): Don't emit the size for function objects.
|
|
|
|
|
Dump the element type of arrays like we dump the pointed-to type of
|
|
|
|
|
pointers, etc.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-dump.c (ctf_dump_format_type): Add 0x to hex type IDs.
|
|
|
|
|
(ctf_dump_header): Add 0x to the hex magic number.
|
|
|
|
|
(ctf_dump_str): Add 0x to the hex string offsets.
|
|
|
|
|
(ctf_dump_membstate_t) <cdm_toplevel_indent>: New.
|
|
|
|
|
(ctf_dump_type): Adjust. Free it when we're done.
|
|
|
|
|
(type_hex_digits): New.
|
|
|
|
|
(ctf_dump_member): Align output depending on the width of the type
|
|
|
|
|
ID being generated. Use printf padding, not a loop, to generate
|
|
|
|
|
indentation.
|
|
|
|
|
|
2021-01-05 21:25:56 +08:00
|
|
|
|
2021-01-05 Nick Alcock <nick.alcock@oracle.com>
|
|
|
|
|
|
|
|
|
|
* ctf-decl.c (ctf_decl_push): Don't print array decls backwards.
|
|
|
|
|
|
2020-12-27 18:32:52 +08:00
|
|
|
|
2021-01-04 Nicolas Boulenguez <nicolas@debian.org>
|
|
|
|
|
|
|
|
|
|
PR 27117
|
|
|
|
|
* configure.ac: Make AC_CONFIG_MACRO_DIR consistent with
|
|
|
|
|
ACLOCAL_AMFLAGS -I dirs.
|
|
|
|
|
* configure: Regenerate.
|
|
|
|
|
|
2021-01-01 06:58:58 +08:00
|
|
|
|
2021-01-01 Alan Modra <amodra@gmail.com>
|
|
|
|
|
|
|
|
|
|
Update year range in copyright notice of all files.
|
|
|
|
|
|
2021-01-01 06:47:13 +08:00
|
|
|
|
For older changes see ChangeLog-2020
|
|
|
|
|
|
|
|
|
|
Copyright (C) 2021 Free Software Foundation, Inc.
|
2019-04-24 01:55:27 +08:00
|
|
|
|
|
2021-01-01 06:47:13 +08:00
|
|
|
|
Copying and distribution of this file, with or without modification,
|
|
|
|
|
are permitted in any medium without royalty provided the copyright
|
|
|
|
|
notice and this notice are preserved.
|
2019-04-24 01:55:27 +08:00
|
|
|
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: change-log
|
|
|
|
|
left-margin: 8
|
2021-01-01 06:47:13 +08:00
|
|
|
|
fill-column: 74
|
2019-04-24 01:55:27 +08:00
|
|
|
|
version-control: never
|
|
|
|
|
End:
|