gimli: (gimli::write::ConvertError)InvalidAttributeValue while gimli::write::Dwarf::from() conversion

I am using Dwarf::from() to convert a readable Dwarf instance to a writable one using convert_address() function as follows:-

fn convert_address(addr: u64) -> Option<gimli::write::Address> {
    Some(gimli::write::Address::Constant(addr))
}
let mut write_dwarf = match gimli::write::Dwarf::from(&dwarf, &convert_address) {
    Ok(write_dwarf) => write_dwarf,
    Err(error) => panic!("Error while Dwarf::from() : {:?}", error),
};

And I’m getting an InvalidAttributeValue error on the Dwarf::from line. As mentioned in Dwarf::from()'s documentation,

convert_address is a function to convert read addresses into the Address type. For non-relocatable addresses, this function may simply return Address::Constant(address). For relocatable addresses, it is the caller’s responsibility to determine the symbol and addend corresponding to the address and return Address::Symbol { symbol, addend }.

I’m simply returning Address::Constant(addr) in convert_address function. Could someone please clarify the changes to be done for relocatable addresses in convert_address function? (Is convert_address the cause for this error?)

Thanks

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 24 (13 by maintainers)

Most upvoted comments

Hi @jjang3, I think you can use this option to disable it. “-gno-variable-location-views” (as mentioned on the page below) https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html

It’s the DW_AT_GNU_locviews attribute, which we don’t support converting or writing yet.

I noticed that object library worked fine with a relocatable object file but had issues with an executable file(couldn’t reproduce all the contents and couldn’t create an executable file).

Correct, object doesn’t support writing executables, only reading them.

On the other hand, gimli seems to be working fine with executable files (I can read DWARF sections and modify them) but has issues when given a relocatable object file as input - (getting InvalidAttributeValue error). Could you please provide your input on this?

I updated rewrite to handle current gimli and object versions, but I wasn’t able to reproduce the InvalidAttributeValue error when running it on sumofn-O0.o. So it may just be that you’re not handling relocations yet.

gimli won’t handle relocations if you’re only using its Reader implementations. You need to provide your own. See ReaderRelocate in rewrite. But note that doesn’t work for relocations in .eh_frame (I’ve filed #484).