Hello Dwarf experts.

I am currently working trying to encode dwarf of binaries with having bi-endian 
variables marked with DW_AT_endianity attribute.
The location calculation for some  variable depends on other variable with 
different endianity, also the value of this other variable is known at runtime.

At the moment I am using location list to calculate the correct location of 
first variable and list of dwarf operators to reverse the endianity of variable 
"__gbloffset__" in below case (I only needed lower 32 bits on 64 bit machine).

0x000001e5: DW_TAG_base_type
 DW_AT_byte_size  (0x04)
  DW_AT_encoding  (DW_ATE_signed)
                DW_AT_name      ("int")
                DW_AT_endianity (DW_END_big)
...
0x00000057:   DW_TAG_variable
                DW_AT_name      ("__gbloffset__")
                DW_AT_type      (0x000001e5 "int")
                DW_AT_external  (true)
                DW_AT_decl_file ("...")
                DW_AT_decl_line (8)
                DW_AT_location  (DW_OP_addr 0) // pre linkage
                DW_AT_linkage_name      ("_gblsection__")

0x00000170:   DW_TAG_variable
                DW_AT_name      ("VAR1")
                DW_AT_type      (0x0000010b "fixed.dec.display.72")
                DW_AT_decl_file ("...")
                DW_AT_decl_line (10)
                DW_AT_location  (DW_OP_addr 0x0, DW_OP_call4 0x57, 
DW_OP_deref_size, 4,
DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit0, DW_OP_shl, DW_OP_and, DW_OP_lit24, 
DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, DW_OP_lit8, DW_OP_shl, 
DW_OP_and, DW_OP_lit8, DW_OP_shl, DW_OP_swap, DW_OP_dup, DW_OP_constu 0xff, 
DW_OP_lit16, DW_OP_shl, DW_OP_and, DW_OP_lit8, DW_OP_shr, DW_OP_swap, 
DW_OP_constu 0xff, DW_OP_lit24, DW_OP_shl, DW_OP_and, DW_OP_lit24, DW_OP_shr, 
DW_OP_swap, DW_OP_or, DW_OP_or, DW_OP_or, DW_OP_plus)
                DW_AT_linkage_name      ("VAR1")


In above snippet of dwarf dump, I am using yellow highlighted list of operators 
to swap the bytes.
I think there should be a support for DW_OP_byte_swap simple operator to 
accomplice this simple task. Does this idea looks like it can be useful? Is 
there any specific reason why dwarf spec does not have it or I am missing 
something subtle.

I hope I conveyed the idea properly, apologies in advanced as English is not my 
first language.

Thanks and regards,

Chirag Patel
Software Engineer | Raincode Labs India
Tel: (+91) 080 41159811
Mob: (+91) 9049336744
www.raincodelabs.com<http://www.raincodelabs.com/>
[linkedin-button]<https://in.linkedin.com/in/chirag-patel->

_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org

Reply via email to