[06/59] libctf, types: allow ctf_type_reference of dynamic slices

Message ID 20200630233146.338613-7-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:30 p.m.
One spot was missed when we rejigged ctf_update into ctf_serialize and
allowed all operations on dynamic containers: ctf_type_reference of
slices.  A dynamic slice's vlen state is stored in the dtu_slice member,
so fetch it from there.

libctf/
	* ctf-types.c (ctf_type_reference): Add support for dynamic slices.
---
 libctf/ctf-types.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

-- 
2.27.0.247.g3dff7de930

Patch

diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index 35253cb3cbc..9c10905ea11 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -680,10 +680,19 @@  ctf_type_reference (ctf_file_t *fp, ctf_id_t type)
       /* Slices store their type in an unusual place.  */
     case CTF_K_SLICE:
       {
+	ctf_dtdef_t *dtd;
 	const ctf_slice_t *sp;
-	ssize_t increment;
-	(void) ctf_get_ctt_size (fp, tp, NULL, &increment);
-	sp = (const ctf_slice_t *) ((uintptr_t) tp + increment);
+
+	if ((dtd = ctf_dynamic_type (ofp, type)) == NULL)
+	  {
+	    ssize_t increment;
+
+	    (void) ctf_get_ctt_size (fp, tp, NULL, &increment);
+	    sp = (const ctf_slice_t *) ((uintptr_t) tp + increment);
+	  }
+	else
+	  sp = &dtd->dtd_u.dtu_slice;
+
 	return sp->cts_type;
       }
     default: