libctf: fix some tabdamage and move some code around
ctf-link.c is unnecessarily confusing because ctf_link_lazy_open is positioned near functions that have nothing to do with opening files. Move it around, and fix some tabdamage that's crept in lately. libctf/ChangeLog 2021-03-18 Nick Alcock <nick.alcock@oracle.com> * ctf-link.c (ctf_link_lazy_open): Move up in the file, to near ctf_link_add_ctf. * ctf-lookup.c (ctf_lookup_symbol_idx): Repair tabdamage. (ctf_lookup_by_sym_or_name): Likewise. * testsuite/libctf-lookup/struct-iteration.c: Likewise. * testsuite/libctf-regression/type-add-unnamed-struct.c: Likewise.
This commit is contained in:
parent
a1f463bedd
commit
087945261c
@ -1,3 +1,12 @@
|
|||||||
|
2021-03-18 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
|
* ctf-link.c (ctf_link_lazy_open): Move up in the file, to near
|
||||||
|
ctf_link_add_ctf.
|
||||||
|
* ctf-lookup.c (ctf_lookup_symbol_idx): Repair tabdamage.
|
||||||
|
(ctf_lookup_by_sym_or_name): Likewise.
|
||||||
|
* testsuite/libctf-lookup/struct-iteration.c: Likewise.
|
||||||
|
* testsuite/libctf-regression/type-add-unnamed-struct.c: Likewise.
|
||||||
|
|
||||||
2021-03-02 Nick Alcock <nick.alcock@oracle.com>
|
2021-03-02 Nick Alcock <nick.alcock@oracle.com>
|
||||||
|
|
||||||
* ctf-create.c (symtypetab_density): Report the symbol name as
|
* ctf-create.c (symtypetab_density): Report the symbol name as
|
||||||
|
@ -189,6 +189,52 @@ ctf_link_add_ctf (ctf_dict_t *fp, ctf_archive_t *ctf, const char *name)
|
|||||||
return ctf_link_add (fp, ctf, name, NULL, 0);
|
return ctf_link_add (fp, ctf, name, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lazily open a CTF archive for linking, if not already open.
|
||||||
|
|
||||||
|
Returns the number of files contained within the opened archive (0 for none),
|
||||||
|
or -1 on error, as usual. */
|
||||||
|
static ssize_t
|
||||||
|
ctf_link_lazy_open (ctf_dict_t *fp, ctf_link_input_t *input)
|
||||||
|
{
|
||||||
|
size_t count;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (input->clin_arc)
|
||||||
|
return ctf_archive_count (input->clin_arc);
|
||||||
|
|
||||||
|
if (input->clin_fp)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* See ctf_link_add_ctf. */
|
||||||
|
#if defined (PIC) || !NOBFD
|
||||||
|
input->clin_arc = ctf_open (input->clin_filename, NULL, &err);
|
||||||
|
#else
|
||||||
|
ctf_err_warn (fp, 0, ECTF_NEEDSBFD, _("cannot open %s lazily"),
|
||||||
|
input->clin_filename);
|
||||||
|
ctf_set_errno (fp, ECTF_NEEDSBFD);
|
||||||
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Having no CTF sections is not an error. We just don't need to do
|
||||||
|
anything. */
|
||||||
|
|
||||||
|
if (!input->clin_arc)
|
||||||
|
{
|
||||||
|
if (err == ECTF_NOCTFDATA)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ctf_err_warn (fp, 0, err, _("opening CTF %s failed"),
|
||||||
|
input->clin_filename);
|
||||||
|
ctf_set_errno (fp, err);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((count = ctf_archive_count (input->clin_arc)) == 0)
|
||||||
|
ctf_arc_close (input->clin_arc);
|
||||||
|
|
||||||
|
return (ssize_t) count;
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a per-CU output CTF dictionary suitable for the given CU, creating and
|
/* Return a per-CU output CTF dictionary suitable for the given CU, creating and
|
||||||
interning it if need be. */
|
interning it if need be. */
|
||||||
|
|
||||||
@ -461,52 +507,6 @@ ctf_link_one_variable (ctf_dict_t *fp, ctf_dict_t *in_fp, const char *name,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lazily open a CTF archive for linking, if not already open.
|
|
||||||
|
|
||||||
Returns the number of files contained within the opened archive (0 for none),
|
|
||||||
or -1 on error, as usual. */
|
|
||||||
static ssize_t
|
|
||||||
ctf_link_lazy_open (ctf_dict_t *fp, ctf_link_input_t *input)
|
|
||||||
{
|
|
||||||
size_t count;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (input->clin_arc)
|
|
||||||
return ctf_archive_count (input->clin_arc);
|
|
||||||
|
|
||||||
if (input->clin_fp)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
/* See ctf_link_add_ctf. */
|
|
||||||
#if defined (PIC) || !NOBFD
|
|
||||||
input->clin_arc = ctf_open (input->clin_filename, NULL, &err);
|
|
||||||
#else
|
|
||||||
ctf_err_warn (fp, 0, ECTF_NEEDSBFD, _("cannot open %s lazily"),
|
|
||||||
input->clin_filename);
|
|
||||||
ctf_set_errno (fp, ECTF_NEEDSBFD);
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Having no CTF sections is not an error. We just don't need to do
|
|
||||||
anything. */
|
|
||||||
|
|
||||||
if (!input->clin_arc)
|
|
||||||
{
|
|
||||||
if (err == ECTF_NOCTFDATA)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ctf_err_warn (fp, 0, err, _("opening CTF %s failed"),
|
|
||||||
input->clin_filename);
|
|
||||||
ctf_set_errno (fp, err);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((count = ctf_archive_count (input->clin_arc)) == 0)
|
|
||||||
ctf_arc_close (input->clin_arc);
|
|
||||||
|
|
||||||
return (ssize_t) count;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct link_sort_inputs_cb_arg
|
typedef struct link_sort_inputs_cb_arg
|
||||||
{
|
{
|
||||||
int is_cu_mapped;
|
int is_cu_mapped;
|
||||||
|
Loading…
Reference in New Issue
Block a user