[PATCH v3 4/5] objdump: Link and display all variables information

Jan Beulich jbeulich@suse.com
Fri Sep 5 06:28:53 GMT 2025


On 04.09.2025 18:55, Guillaume VACHERIAS - foss wrote:
> On 01.09.2025 19:50, Guillaume VACHERIAS wrote:
>> @@ -13692,6 +13942,346 @@ struct dwarf_section_display debug_displays[] =
>>  /* A static assertion.  */
>>  extern int debug_displays_assert[ARRAY_SIZE (debug_displays) == max ? 1 : -1];
>>  
>> +static void
>> +do_link_variable_information (void *ptr_die_type,
>> +			      enum types die_type,
>> +			      void *target_die_type,
>> +			      enum types die_type_targeted)
>> +{
>> +  switch (die_type)
>> +    {
>> +      case UNKNOWN_TYPE:
>> +      case BASE_TYPE:
>> +      case ENUM_TYPE:
>> +      case STRUCT_TYPE:
>> +      case UNION_TYPE:
>> +	break;
>> +      case MEMBER_TYPE:
>> +	((member_type *) ptr_die_type)->type = die_type_targeted;
>> +	((member_type *) ptr_die_type)->ptr_type = target_die_type;
> 
> This is awkward, it being just a single assignment (each) would be better.
> And this remark goes along with my earlier one towards it not being possible
> to identify the type from just the structure. You did drop the odd union (in
> patch 3), but that wasn't really what I was after. Instead I had tried to
> hint at the union wanting to gain a common, identifying field (along the
> lines of what allows a union to become a transparent union, when making use
> of that gcc extension).
> 
> I'm sorry, I'm not sure if I can find a way to reduce this as only a single assignment.
> As you said, it is not possible to identify the type from just the structure hence the
> need of the field "type" to serve as tag of the structure type.
> I will definitively use union which would remove all the unnecessary cast in v4, but the tag
> is still needed in order to determine which field is valid.
> Is there an example of implementation which permits to remove the tagged field (enum types) or
> I didn't correctly understand your suggestion ?

What I'm suggesting is to add a type field as the first element of each of
the structures forming the union. One "generic" union element then would be
"just a type field". (Thinking about it, my reference to transparent unions
may have been misleading rather than helpful here. Sorry.)

Jan


More information about the Binutils mailing list