Skip to content

Commit

Permalink
Merge pull request #16097 from keithc-ca/jpackcore
Browse files Browse the repository at this point in the history
Include all ELF objects listed in FILE notes
  • Loading branch information
pshipton committed Oct 13, 2022
2 parents e8abb75 + 147336c commit f484da3
Showing 1 changed file with 8 additions and 4 deletions.
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

0 comments on commit f484da3

Please sign in to comment.