aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
Diffstat (limited to 'libctf')
-rw-r--r--libctf/NEWS9
-rw-r--r--libctf/ctf-link.c37
-rw-r--r--libctf/ctf-serialize.c23
3 files changed, 57 insertions, 12 deletions
diff --git a/libctf/NEWS b/libctf/NEWS
index 956cca8..f4e5973 100644
--- a/libctf/NEWS
+++ b/libctf/NEWS
@@ -1,5 +1,14 @@
-*- text -*-
+Changes in 2.39:
+
+* New features
+
+** The CTF variable section (if generated via ld --ctf-variables) now contains
+ entries for static functions, hidden functions, and other functions with
+ no associated symbol. The associated type is of kind CTF_K_FUNCTION.
+ (No change if --ctf-variables is not specified, which is the default.)
+
Changes in 2.37:
* New features
diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index ee83605..d92a693 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -807,7 +807,12 @@ ctf_link_deduplicating_close_inputs (ctf_dict_t *fp, ctf_dynhash_t *cu_names,
return 0;
}
-/* Do a deduplicating link of all variables in the inputs. */
+/* Do a deduplicating link of all variables in the inputs.
+
+ Also, if we are not omitting the variable section, integrate all symbols from
+ the symtypetabs into the variable section too. (Duplication with the
+ symtypetab section in the output will be eliminated at serialization time.) */
+
static int
ctf_link_deduplicating_variables (ctf_dict_t *fp, ctf_dict_t **inputs,
size_t ninputs, int cu_mapped)
@@ -820,6 +825,8 @@ ctf_link_deduplicating_variables (ctf_dict_t *fp, ctf_dict_t **inputs,
ctf_id_t type;
const char *name;
+ /* First the variables on the inputs. */
+
while ((type = ctf_variable_next (inputs[i], &it, &name)) != CTF_ERR)
{
if (ctf_link_one_variable (fp, inputs[i], name, type, cu_mapped) < 0)
@@ -830,6 +837,34 @@ ctf_link_deduplicating_variables (ctf_dict_t *fp, ctf_dict_t **inputs,
}
if (ctf_errno (inputs[i]) != ECTF_NEXT_END)
return ctf_set_errno (fp, ctf_errno (inputs[i]));
+
+ /* Next the symbols. We integrate data symbols even though the compiler
+ is currently doing the same, to allow the compiler to stop in
+ future. */
+
+ while ((type = ctf_symbol_next (inputs[i], &it, &name, 0)) != CTF_ERR)
+ {
+ if (ctf_link_one_variable (fp, inputs[i], name, type, 1) < 0)
+ {
+ ctf_next_destroy (it);
+ return -1; /* errno is set for us. */
+ }
+ }
+ if (ctf_errno (inputs[i]) != ECTF_NEXT_END)
+ return ctf_set_errno (fp, ctf_errno (inputs[i]));
+
+ /* Finally the function symbols. */
+
+ while ((type = ctf_symbol_next (inputs[i], &it, &name, 1)) != CTF_ERR)
+ {
+ if (ctf_link_one_variable (fp, inputs[i], name, type, 1) < 0)
+ {
+ ctf_next_destroy (it);
+ return -1; /* errno is set for us. */
+ }
+ }
+ if (ctf_errno (inputs[i]) != ECTF_NEXT_END)
+ return ctf_set_errno (fp, ctf_errno (inputs[i]));
}
return 0;
}
diff --git a/libctf/ctf-serialize.c b/libctf/ctf-serialize.c
index 89f1ac0..cc9e59d 100644
--- a/libctf/ctf-serialize.c
+++ b/libctf/ctf-serialize.c
@@ -431,12 +431,12 @@ emit_symtypetab_index (ctf_dict_t *fp, ctf_dict_t *symfp, uint32_t *dp,
return 0;
}
-/* Delete data symbols that have been assigned names from the variable section.
- Must be called from within ctf_serialize, because that is the only place
- you can safely delete variables without messing up ctf_rollback. */
+/* Delete symbols that have been assigned names from the variable section. Must
+ be called from within ctf_serialize, because that is the only place you can
+ safely delete variables without messing up ctf_rollback. */
static int
-symtypetab_delete_nonstatic_vars (ctf_dict_t *fp, ctf_dict_t *symfp)
+symtypetab_delete_nonstatics (ctf_dict_t *fp, ctf_dict_t *symfp)
{
ctf_dvdef_t *dvd, *nvd;
ctf_id_t type;
@@ -445,8 +445,10 @@ symtypetab_delete_nonstatic_vars (ctf_dict_t *fp, ctf_dict_t *symfp)
{
nvd = ctf_list_next (dvd);
- if (((type = (ctf_id_t) (uintptr_t)
- ctf_dynhash_lookup (fp->ctf_objthash, dvd->dvd_name)) > 0)
+ if ((((type = (ctf_id_t) (uintptr_t)
+ ctf_dynhash_lookup (fp->ctf_objthash, dvd->dvd_name)) > 0)
+ || (type = (ctf_id_t) (uintptr_t)
+ ctf_dynhash_lookup (fp->ctf_funchash, dvd->dvd_name)) > 0)
&& ctf_dynhash_lookup (symfp->ctf_dynsyms, dvd->dvd_name) != NULL
&& type == dvd->dvd_type)
ctf_dvd_delete (fp, dvd);
@@ -560,13 +562,12 @@ ctf_symtypetab_sect_sizes (ctf_dict_t *fp, emit_symtypetab_state_t *s,
/* If we are filtering symbols out, those symbols that the linker has not
reported have now been removed from the ctf_objthash and ctf_funchash.
- Delete entries from the variable section that duplicate newly-added data
- symbols. There's no need to migrate new ones in, because the compiler
- always emits both a variable and a data symbol simultaneously, and
- filtering only happens at final link time. */
+ Delete entries from the variable section that duplicate newly-added
+ symbols. There's no need to migrate new ones in: we do that (if necessary)
+ in ctf_link_deduplicating_variables. */
if (s->filter_syms && s->symfp->ctf_dynsyms &&
- symtypetab_delete_nonstatic_vars (fp, s->symfp) < 0)
+ symtypetab_delete_nonstatics (fp, s->symfp) < 0)
return -1;
return 0;