Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include all ELF objects listed in FILE notes #16097

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ private static abstract class ElfFile {
private short _programHeaderCount = 0;
private short _sectionHeaderEntrySize = 0;
private short _sectionHeaderCount = 0;
// The set of ELF objects mentioned in FILE notes.
final Set<String> _allElfFileNames = new HashSet<>();
// Maps to a set of paths of loaded shared libraries for a particular 'soname'.
final Map<String, Set<String>> _librariesBySOName = new HashMap<>();
private List<DataEntry> _processEntries = new ArrayList<>();
Expand Down Expand Up @@ -1035,6 +1037,8 @@ private void readFileNotes(long offset) throws IOException {
continue;
}

_allElfFileNames.add(fileName);

String soname = result.getSONAME();

if (soname != null) {
Expand Down Expand Up @@ -1663,14 +1667,11 @@ private List<?> readModules(Builder builder, Object addressSpace, String executa
continue;
}

// add all matching names found in the file notes
// use soname if we could't find something better in the file notes
Set<String> libs = _file._librariesBySOName.get(soname);

if (libs == null || libs.isEmpty()) {
// use soname if we could't find something better in the file notes
_additionalFileNames.add(soname);
} else {
_additionalFileNames.addAll(libs);
}
} catch (Exception ex) {
// We can't tell a loaded module from a loaded something else without trying to open it
Expand Down Expand Up @@ -2339,6 +2340,9 @@ public void extract(Builder builder) {
builder.setOSType("ELF"); //$NON-NLS-1$
builder.setCPUType(_file._arch.toString());
builder.setCPUSubType(readStringAt(_platformIdAddress));

// Include all libraries mentioned in NT_FILE notes.
_additionalFileNames.addAll(_file._allElfFileNames);
} catch (CorruptCoreException | IOException | MemoryAccessException e) {
// TODO throw exception or notify builder?
}
Expand Down