labath added a comment.

I just realized I didn't press "sumbit" yesterday...

Comment at: lldb/source/Symbol/ObjectFile.cpp:480-486
+  size_t ret = data.SetData(m_data, offset, length);
+  // DataExtractor::SetData copies the address byte size from m_data, but
+  // m_data's address byte size is only set from sizeof(void*), and we can't
+  // access subclasses GetAddressByteSize() when setting up m_data in the
+  // constructor.
+  data.SetAddressByteSize(GetAddressByteSize());
+  return ret;
mstorsjo wrote:
> clayborg wrote:
> > I would vote to make this happen within DataExtractor::SetData(const 
> > DataExtractor &...)
> Do you mean that we'd extend `DataExtractor::SetData(const DataExtractor 
> &...)` to take a byte address size parameter, or that we'd update `m_data`'s 
> byte address size before doing `data.SetData()` here?
> Ideally I'd set the right byte address size in `m_data` as soon as it is 
> known and available. It's not possible to do this in `ObjectFile`'s 
> constructor, as that is called before the subclass is constructed and its 
> virtual methods are available, but is there a better point in the lifetime 
> where we could update it?
I too would prefer that, but I couldn't see a way to achieve that (which is why 
I stamped this version).

Today, with a fresh set of eyes, I think it may be reasonable to have this 
happen in `ObjectFile::ParseHeader`. After the header has been parsed, all 
object formats (I hope) should be able to determine their address size and 
endianness, and the operating invariant would be that the address size is only 
valid after the ParseHeader has been called. WDYT?

  rG LLVM Github Monorepo


lldb-commits mailing list

Reply via email to