Make LD_DEBUG more user-friendly.
This is more self-explanatory than arbitrary integers, actually does
explain itself if you typo or say LD_DEBUG=help, and makes statistics
and timing available without recompilation.
Some of the groups could probably use a little tweaking, and we could
probably use some more groups, but I think this is already better than
what we have, and the initial change moving LD_DEBUG from integers to
names should probably minimize the amount of change that regard.
There's also the continuing question of whether statistics and timing
should just be deleted. They're not super useful as-is, and we should
think about whether we want to make them more useful or just remove them.
The timing stuff in particular is probably questionable, because
systrace is probably a better way to do anything like that? But that too
sounds like a question for another day.
Bug: http://b/309528372
Test: adb shell LD_DEBUG=<various things> date
Change-Id: I52b96c4892a41f9d24873122aebe5c272f39cdae
diff --git a/linker/linker_note_gnu_property.cpp b/linker/linker_note_gnu_property.cpp
index be1aebc..082a604 100644
--- a/linker/linker_note_gnu_property.cpp
+++ b/linker/linker_note_gnu_property.cpp
@@ -62,7 +62,7 @@
continue;
}
- TRACE("\"%s\" PT_GNU_PROPERTY: found at segment index %zu", name, i);
+ LD_DEBUG(props, "\"%s\" PT_GNU_PROPERTY: found at segment index %zu", name, i);
// Check segment size.
if (phdr[i].p_memsz < sizeof(ElfW(NhdrGNUProperty))) {
@@ -90,7 +90,7 @@
}
}
- TRACE("\"%s\" PT_GNU_PROPERTY: not found", name);
+ LD_DEBUG(props, "\"%s\" PT_GNU_PROPERTY: not found", name);
return nullptr;
}
@@ -122,7 +122,7 @@
// The total length of the program property array is in _bytes_.
ElfW(Word) offset = 0;
while (offset < note_nhdr->nhdr.n_descsz) {
- DEBUG("\"%s\" .note.gnu.property: processing at offset 0x%x", name, offset);
+ LD_DEBUG(props, "\"%s\" .note.gnu.property: processing at offset 0x%x", name, offset);
// At least the "header" part must fit.
// The ABI doesn't say that pr_datasz can't be 0.
@@ -161,14 +161,14 @@
const ElfW(Word) flags = *reinterpret_cast<const ElfW(Word)*>(&property->pr_data[0]);
properties_.bti_compatible = (flags & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) != 0;
if (properties_.bti_compatible) {
- INFO("[ BTI compatible: \"%s\" ]", name);
+ LD_DEBUG(props, "[ BTI compatible: \"%s\" ]", name);
}
break;
}
#endif
default:
- DEBUG("\"%s\" .note.gnu.property: found property pr_type %u pr_datasz 0x%x", name,
- property->pr_type, property->pr_datasz);
+ LD_DEBUG(props, "\"%s\" .note.gnu.property: found property pr_type %u pr_datasz 0x%x",
+ name, property->pr_type, property->pr_datasz);
break;
}