Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tcf-dev] Debugging ARM binary fails because of non-zero VMA/LMA on debug sections

We have a problem where an ARM AArch64 binary cannot be debugged.
This binary when dumped with objdump has non-zero VMA/LMA (equally valued)
for the debug sections. The debug sections are part of any segment, so
they are not actually loaded, but the non-zero value seem to confuse TCF,
while GDB still functions for the same binary.

So even though setting VMA/LMA makes no sense for sections that are
not loaded, this seems to how the ARM compiler or linker works,
and we would like the TCF to support this.

I'm not sure what to make of this, but here is a forum post about
VMA/LMA and an answer from an ARM employee:
https://community.arm.com/tools/f/discussions/7189/how-to-load-sections-to-lma-not-vma-during-debugging-with-elf-file

Since I cannot provide the original binary because of legal reasons,
I have created a simple example which has creates an x86 binary where
the debug sections all have the same VMA/LMA and this binary
can be debugged with GDB to some extent, but fails to be debugged with TCF.

When debugging TCF while debugging the original, I managed to get the
symbol information for the first stack frame using the following patch,
but other queries (address-to-symbol) failed, so it is not a fix, but
perhaps narrows down the problem.

If this problem sounds like something that can be fixed so that
TCF can be used with binaries created from ARM DS5, I will write
a bug report and attach the (buildable with gcc) test binary.

Thanks,
Claes

diff --git a/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c b/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c
index 6d2ee3d7453..1c67b3d1a12 100644
--- a/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c
+++ b/src/extensions/tcf-agent.mirror/tcf_agent/agent/tcf/services/dwarfcache.c
@@ -127,7 +127,7 @@ static CompUnit * add_comp_unit(ContextAddress ID) {
 static CompUnit * find_comp_unit(ELF_Section * Section, ContextAddress ObjID) {
     ObjectHashTable * HashTable = sCache->mObjectHashTable + Section->index;
     if (sCompUnit != NULL && sCompUnit->mDesc.mSection == Section) {
-        ContextAddress ID = sCompUnit->mDesc.mSection->addr + sCompUnit->mDesc.mUnitOffs;
+        ContextAddress ID = sCompUnit->mDesc.mUnitOffs;
         if (ID <= ObjID && ID + sCompUnit->mDesc.mUnitSize > ObjID) return sCompUnit;
     }
     if (HashTable->mCompUnitsIndex != NULL) {
@@ -136,7 +136,7 @@ static CompUnit * find_comp_unit(ELF_Section * Section, ContextAddress ObjID) {
         while (l < h) {
             unsigned i = (l + h) / 2;
             CompUnit * unit = HashTable->mCompUnitsIndex[i];
-            ContextAddress ID = unit->mDesc.mSection->addr + unit->mDesc.mUnitOffs;
+            ContextAddress ID = unit->mDesc.mUnitOffs;
             if (ID > ObjID) {
                 h = i;
             }

----------------------------------------------------------------------
Intel Sweden AB
Registered Office: Isafjordsgatan 30B, 164 40 Kista, Stockholm, Sweden
Registration Number: 556189-6027

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



Back to the top