[46/59] ctf, link: fix spurious conflicts of variables in the variable section

Message ID 20200630233146.338613-47-nick.alcock@oracle.com
State New
Headers show
Series
  • Deduplicating CTF linker
Related show

Commit Message

H.J. Lu via Binutils June 30, 2020, 11:31 p.m.
When we link a CTF variable, we check to see if it already exists in the
parent dict first: if it does, and it has a type the same as the type we
would populate it with, we assume we don't need to do anything:
otherwise, we populate it in a per-CU child.

Or that's what we should be doing.  Instead, we check if the type is the
same as the type in *source dict*, which is going to be a completely
different value!  So we end up concluding all variables are conflicting,
bloating up output possibly quite a lot (variables aren't big in and of
themselves, but each drags around a strtab entry, and CTF dicts in a CTF
archive do not share their strtabs -- one of many problems with CTF
archives as presently constituted.)

Fix trivial: check the right type.

libctf/
	* ctf-link.c (ctf_link_one_variable): Check the dst_type for
	conflicts, not the source type.
---
 libctf/ctf-link.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.27.0.247.g3dff7de930

Comments

H.J. Lu via Binutils July 1, 2020, 10:40 a.m. | #1
On 1 Jul 2020, Nick Alcock via Binutils outgrape:

> When we link a CTF variable, we check to see if it already exists in the

> parent dict first: if it does, and it has a type the same as the type we

> would populate it with, we assume we don't need to do anything:

> otherwise, we populate it in a per-CU child.


Well, OK, this commit log is getting changed. It stuck out a mile in the
mailing list summary view :)

'ctf'? No, libctf!

Patch

diff --git a/libctf/ctf-link.c b/libctf/ctf-link.c
index 3c96604b36a..7b0ac386dec 100644
--- a/libctf/ctf-link.c
+++ b/libctf/ctf-link.c
@@ -584,7 +584,7 @@  ctf_link_one_variable (const char *name, ctf_id_t type, void *arg_)
 	    }
 
 	  /* Already present?  Nothing to do.  */
-	  if (dvd && dvd->dvd_type == type)
+	  if (dvd && dvd->dvd_type == dst_type)
 	    return 0;
 	}
     }