From 5060eb7bf84aea87997bcb0af16d2e44d4465083 Mon Sep 17 00:00:00 2001 From: ac2pic Date: Wed, 15 Jun 2022 16:46:29 -0500 Subject: [PATCH 1/7] Update buildNIDEntry --- pkg/oelf/OELFGenDynlibData.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index 5c621b5..c04b2b8 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -514,7 +514,7 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { // Currently assumes module (and thus library) ID will always be < 26. // Currently matches library ID to module ID. // Returns the final constructed string of the NID entry. -func buildNIDEntry(symbolName string, moduleId int) string { +func buildNIDEntry(symbolName string, libraryId int, moduleId int) string { nid := "" // Allow unknown symbols and allow arbitrary NIDs if the prefix is `__PS4_NID_` @@ -526,11 +526,11 @@ func buildNIDEntry(symbolName string, moduleId int) string { nid = calculateNID(symbolName) } - // Format: [NID Hash] + '#' + [Module Index] + '#' + [Library Index] + // Format: [NID Hash] + '#' + [Library Index] + "#" + [Module Index] + libraryIdChar := string(_indexEncodingTable[libraryId]) moduleIdChar := string(_indexEncodingTable[moduleId]) - libraryIdChar := moduleIdChar - nid += "#" + moduleIdChar + "#" + libraryIdChar + "\x00" + nid += "#" + libraryIdChar + "#" + moduleIdChar + "\x00" return nid } From 7e7593fb2acf1220c183e58158c7dd66f1e90ad8 Mon Sep 17 00:00:00 2001 From: ac2pic Date: Sat, 25 Jun 2022 19:03:57 -0500 Subject: [PATCH 2/7] WIP: Add multilib module support --- pkg/oelf/OELF.go | 4 +- pkg/oelf/OELFGenDynlibData.go | 150 ++++++++++++++++++++++++++-------- pkg/oelf/OELFStrangeLibs.go | 143 ++++++++++++++++++++++++++++++++ 3 files changed, 260 insertions(+), 37 deletions(-) create mode 100644 pkg/oelf/OELFStrangeLibs.go diff --git a/pkg/oelf/OELF.go b/pkg/oelf/OELF.go index aca72f3..748b783 100644 --- a/pkg/oelf/OELF.go +++ b/pkg/oelf/OELF.go @@ -17,7 +17,9 @@ type OrbisElf struct { LibraryName string ElfToConvertName string ElfToConvert *elf.File - ModuleSymbolDictionary *OrderedMap + LibrarySymbolDictionary *OrderedMap + ModuleList []string + LibraryModuleDictionary *OrderedMap WrittenBytes int IsLibrary bool diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index c04b2b8..8f3c045 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -94,7 +94,8 @@ var _moduleToLibDictionary = map[string]string{ var ( _libraryOffsets []uint64 - _moduleOffsets []uint64 + _importedLibraryOffsets []uint64 + _importedModuleOffsets []uint64 _offsetOfProjectName uint64 _offsetOfFileName uint64 @@ -133,7 +134,10 @@ func OpenLibrary(name string, sdkPath string, libPath string) (*elf.File, error) func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPath string) error { var libraryObjs []*elf.File - orbisElf.ModuleSymbolDictionary = NewOrderedMap() + orbisElf.LibrarySymbolDictionary = NewOrderedMap() + orbisElf.LibraryModuleDictionary = NewOrderedMap() + + orbisElf.ModuleList = make([]string, 0, 10) // Get all the imported libraries, create dictionary keys for them, and open them for symbol searching libraries, err := orbisElf.ElfToConvert.ImportedLibraries() @@ -155,7 +159,10 @@ func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPat // Ensure libkernel is the first library if libraryObj, err := OpenLibrary("libkernel.so", sdkPath, libPath); err == nil { libraryObjs = append(libraryObjs, libraryObj) - orbisElf.ModuleSymbolDictionary.Set("libkernel", []string{}) + orbisElf.LibrarySymbolDictionary.Set("libkernel", []string{}) + + orbisElf.LibraryModuleDictionary.Set("libkernel", "libkernel") + orbisElf.ModuleList = append(orbisElf.ModuleList, "libkernel") } else { return err } @@ -176,10 +183,41 @@ func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPat // Add it to the dictionary purifiedLibrary := strings.Replace(library, ".so", "", 1) - orbisElf.ModuleSymbolDictionary.Set(purifiedLibrary, []string{}) + orbisElf.LibrarySymbolDictionary.Set(purifiedLibrary, []string{}) + + + // Assume module name is the library name + moduleName := purifiedLibrary + // Check if it is a weird library hidden inside a module + if mn, ok := _extraLibraryToModule[purifiedLibrary]; ok { + moduleName = mn + } + + // Prevent duplicate entries + if !contains(orbisElf.ModuleList, moduleName) { + orbisElf.ModuleList = append(orbisElf.ModuleList, moduleName) + } + + orbisElf.LibraryModuleDictionary.Set(purifiedLibrary, moduleName) } - // Create a cache of libraries to symbols for better performance + var rolsd = NewOrderedMap() + + for _, module := range orbisElf.ModuleList { + rolsd.Set(module, orbisElf.LibrarySymbolDictionary.Get(module)) + } + + + for _, library := range orbisElf.LibrarySymbolDictionary.Keys() { + libNa := library.(string) + if !contains(orbisElf.ModuleList, libNa) { + rolsd.Set(libNa, orbisElf.LibraryModuleDictionary.Get(libNa)) + } + } + + orbisElf.LibrarySymbolDictionary = rolsd + + // Create a cache of libraries to symbols for better performancek librarySymbolCache := make(map[*elf.File][]elf.Symbol) for _, libraryObj := range libraryObjs { @@ -213,10 +251,10 @@ func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPat if foundSymbol { library := strings.Replace(libraries[i], ".so", "", 1) - symbolList := orbisElf.ModuleSymbolDictionary.Get(library).([]string) + symbolList := orbisElf.LibrarySymbolDictionary.Get(library).([]string) symbolList = append(symbolList, symbolName) - orbisElf.ModuleSymbolDictionary.Set(library, symbolList) + orbisElf.LibrarySymbolDictionary.Set(library, symbolList) } } } @@ -255,7 +293,7 @@ func (orbisElf *OrbisElf) GenerateDynlibData(sdkPath string, libPath string) err // Write linking tables tableOffsets.stringTable = segmentSize - tableOffsets.stringTableSz, err = writeStringTable(orbisElf, orbisElf.ElfToConvertName, orbisElf.LibraryName, orbisElf.ModuleSymbolDictionary, &segmentData) + tableOffsets.stringTableSz, err = writeStringTable(orbisElf, orbisElf.ElfToConvertName, orbisElf.LibraryName, orbisElf.ModuleList, orbisElf.LibrarySymbolDictionary, &segmentData) if err != nil { return err } @@ -321,13 +359,13 @@ func writeFingerprint(fingerprint string, segmentData *[]byte) uint64 { // writeStringTable writes the module table, project meta data, and NID table to segmentData. Returns the number of bytes // written. -func writeStringTable(orbisElf *OrbisElf, projectName string, libName string, moduleSymbolDictionary *OrderedMap, segmentData *[]byte) (uint64, error) { +func writeStringTable(orbisElf *OrbisElf, projectName string, libName string, moduleList []string, librarySymbolDictionary *OrderedMap, segmentData *[]byte) (uint64, error) { _sizeOfStrTable = 0 // Write the first null module entry writeNullBytes(segmentData, 1) - _sizeOfStrTable += writeModuleTable(moduleSymbolDictionary, segmentData) + _sizeOfStrTable += writeModuleTable(moduleList, librarySymbolDictionary, segmentData) _offsetOfProjectName = _sizeOfStrTable + 1 // Account for null entry _sizeOfStrTable += writeProjectMetaData(projectName, libName, segmentData) @@ -349,15 +387,14 @@ func writeStringTable(orbisElf *OrbisElf, projectName string, libName string, mo // writeModuleTable writes the module string table using the given moduleSymbolDictionary to segmentData. Returns the // number of bytes written. -func writeModuleTable(moduleSymbolDictionary *OrderedMap, segmentData *[]byte) uint64 { +func writeModuleTable(moduleList []string, librarySymbolDictionary *OrderedMap, segmentData *[]byte) uint64 { moduleTableBuff := new(bytes.Buffer) - modules := moduleSymbolDictionary.Keys() + libraries := librarySymbolDictionary.Keys() - // Write library list - for _, module := range modules { - moduleStr := module.(string) - moduleStr = strings.Replace(moduleStr, "_stub", "", 1) + // Write library prx list + for _, module := range moduleList { + moduleStr := strings.Replace(module, "_stub", "", 1) // Record the offset of the library for processing later libName := _moduleToLibDictionary[moduleStr] @@ -375,20 +412,42 @@ func writeModuleTable(moduleSymbolDictionary *OrderedMap, segmentData *[]byte) u moduleTableBuff.WriteString(libName) } + // Write module list - for _, module := range modules { - moduleStr := module.(string) - moduleStr = strings.Replace(moduleStr, "_stub", "", 1) + for _, module := range moduleList { + moduleStr := strings.Replace(module, "_stub", "", 1) // Record the offset of the library for processing later moduleName := moduleStr + "\x00" moduleOffset := uint64(len(moduleTableBuff.Bytes())) + 1 + + _importedModuleOffsets = append(_importedLibraryOffsets, moduleOffset) + + // Assume library name is module name too + _importedLibraryOffsets = append(_importedLibraryOffsets, moduleOffset) + // Add to the table - _moduleOffsets = append(_moduleOffsets, moduleOffset) moduleTableBuff.WriteString(moduleName) } + for _, library := range libraries { + libraryStr := library.(string) + libraryStr = strings.Replace(libraryStr, "stub", "", 1) + + if contains(moduleList, libraryStr) { + continue + } + + libraryName := libraryStr + "\x00" + libraryOffset := uint64(len(moduleTableBuff.Bytes())) + 1 + + _importedLibraryOffsets = append(_importedLibraryOffsets, libraryOffset) + + // Add to the table + moduleTableBuff.WriteString(libraryName) + } + // The filename of the project will proceed these entries in the string table, and is needed for dynamic table // generation, so we'll record it here. _offsetOfFileName = uint64(len(moduleTableBuff.Bytes())) + 1 @@ -448,7 +507,8 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { // Iterate the symbol table of the input ELF to generate entries. We don't need to check err here because we've already // checked it before we reach this point. symbols, _ := orbisElf.ElfToConvert.DynamicSymbols() - modules := orbisElf.ModuleSymbolDictionary.Keys() + libraries := orbisElf.LibrarySymbolDictionary.Keys() + modules := orbisElf.ModuleList // Get libc index for Need_sceLibc libcModuleIndex := -1 @@ -462,34 +522,52 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { // Each symbol might need an NID entry for _, symbol := range symbols { + symbolLibraryIndex := -1 symbolModuleIndex := -1 + libraryName := "" + moduleName := "" + // Skip symbols that have a valid section index - they're defined in the ELF and are not external if symbol.Section != elf.SHN_UNDEF { continue } - // Check which library this symbol is from - for moduleIndex, module := range modules { - moduleSymbols := orbisElf.ModuleSymbolDictionary.Get(module).([]string) + for idx, library := range libraries { + libSyms := orbisElf.LibrarySymbolDictionary.Get(library).([]string) + if contains(libSyms, symbol.Name) { + libraryName = library.(string) + symbolLibraryIndex = idx + break + } + } + + if symbolLibraryIndex < 0 { + return 0, errors.New(fmt.Sprintf("missing library for symbol (%s)", symbol.Name)) + } - if contains(moduleSymbols, symbol.Name) { - symbolModuleIndex = moduleIndex + moduleName = orbisElf.LibraryModuleDictionary.Get(libraryName).(string) + for idx, module := range modules { + if moduleName == module { + symbolModuleIndex = idx break } } if symbolModuleIndex < 0 { - return 0, errors.New(fmt.Sprintf("missing module for symbol (%s)", symbol.Name)) + return 0, errors.New(fmt.Sprintf("missing module %s for symbol (%s)", moduleName, symbol.Name)) } + // TODO: Comment out when not debugging + fmt.Printf("[%s;] %s: %d %s: %d \n", symbol.Name, moduleName, symbolModuleIndex, libraryName, symbolLibraryIndex) + // Build the NID and insert it into the table - nidTableBuff.WriteString(buildNIDEntry(symbol.Name, 1+symbolModuleIndex)) + nidTableBuff.WriteString(buildNIDEntry(symbol.Name, 1+symbolLibraryIndex, 1+symbolModuleIndex)) } if libcModuleIndex >= 0 { // Add an additional symbol for Need_sceLibc - nidTableBuff.WriteString(buildNIDEntry("Need_sceLibc", 1+libcModuleIndex)) + nidTableBuff.WriteString(buildNIDEntry("Need_sceLibc", 1+libcModuleIndex, 1+libcModuleIndex)) } // Add exported symbols for libraries @@ -500,7 +578,7 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { for _, symbol := range moduleSymbols { // Only export global symbols that we have values for if ((symbol.Info>>4&0xf) == uint8(elf.STB_GLOBAL) || (symbol.Info>>4&0xf) == uint8(elf.STB_WEAK)) && symbol.Value != 0 { - nidTableBuff.WriteString(buildNIDEntry(symbol.Name, moduleId)) + nidTableBuff.WriteString(buildNIDEntry(symbol.Name, moduleId, moduleId)) } } } @@ -530,7 +608,7 @@ func buildNIDEntry(symbolName string, libraryId int, moduleId int) string { libraryIdChar := string(_indexEncodingTable[libraryId]) moduleIdChar := string(_indexEncodingTable[moduleId]) - nid += "#" + libraryIdChar + "#" + moduleIdChar + "\x00" + nid += "#" + moduleIdChar + "#" + libraryIdChar + "\x00" return nid } @@ -602,8 +680,8 @@ func writeSymbolTable(orbisElf *OrbisElf, segmentData *[]byte) uint64 { } - modules := orbisElf.ModuleSymbolDictionary.Keys() - + // Assume library name is module name + modules := orbisElf.LibrarySymbolDictionary.Keys() // Get libc index for Need_sceLibc libcModuleIndex := -1 @@ -898,7 +976,7 @@ func writeDynamicTable(orbisElf *OrbisElf, tableOffsets *TableOffsets, segmentDa } // Imported modules - for i, moduleOffset := range _moduleOffsets { + for i, moduleOffset := range _importedModuleOffsets { moduleId := uint16(1 + i) moduleValue := makeModuleTagValue(uint32(moduleOffset), 1, 1, moduleId) writeDynamicEntry(dynamicTableBuff, DT_SCE_IMPORT_MODULE, moduleValue) @@ -914,9 +992,9 @@ func writeDynamicTable(orbisElf *OrbisElf, tableOffsets *TableOffsets, segmentDa } // Imported libraries - for i, moduleOffset := range _moduleOffsets { + for i, libraryOffset := range _importedLibraryOffsets { libraryId := uint16(1 + i) - libraryValue := makeLibTagValue(uint32(moduleOffset), 1, libraryId) + libraryValue := makeLibTagValue(uint32(libraryOffset), 1, libraryId) libraryAttr := makeLibAttrTagValue(0x9, libraryId) writeDynamicEntry(dynamicTableBuff, DT_SCE_IMPORT_LIB, libraryValue) diff --git a/pkg/oelf/OELFStrangeLibs.go b/pkg/oelf/OELFStrangeLibs.go new file mode 100644 index 0000000..1044685 --- /dev/null +++ b/pkg/oelf/OELFStrangeLibs.go @@ -0,0 +1,143 @@ +package oelf + +var _extraLibraryToModule = map[string]string{ + "libSceUserServiceForNpToolkit": "libSceUserService", + "libSceUserServiceForShellCore": "libSceUserService", + "libSceUserServiceRegisteredUserIdList": "libSceUserService", + "libkernel_avlfmem": "libkernel", + "libkernel_cpumode": "libkernel", + "libkernel_cpumode_platform": "libkernel", + "libkernel_dmem_aliasing": "libkernel", + "libkernel_dmem_aliasing2": "libkernel", + "libkernel_dmem_aliasing2_for_dev": "libkernel", + "libkernel_exception": "libkernel", + "libkernel_jvm": "libkernel", + "libkernel_module_extension": "libkernel", + "libkernel_module_info": "libkernel", + "libkernel_module_load_check": "libkernel", + "libkernel_pre250mmap": "libkernel", + "libkernel_ps2emu": "libkernel", + "libkernel_psmkit": "libkernel", + "libkernel_qadisc": "libkernel", + "libkernel_sysc_se": "libkernel", + "libkernel_unity": "libkernel", + "libSceCoredump": "libkernel", + "libSceCoredump_debug": "libkernel", + "libSceOpenPsId": "libkernel", + "libScePosix": "libkernel", + "libSceNpManagerCompat": "libSceNpManager", + "libSceNpManagerForSys": "libSceNpManager", + "libSceNpManagerForToolkit": "libSceNpManager", + "libSceNpManagerIsPlusMember": "libSceNpManager", + "libkernel_devtoollog": "libkernel", + "libSceIpmiDbg": "libSceIpmi", + "libSceGameCustomDataDialog": "libGameCustomDataDialog", + "libSceGameCustomDataDialogCompat": "libGameCustomDataDialog", + "libSceWebBrowserDialogLimited": "libSceWebBrowserDialog", + "libSceNpMatching2Compat": "libSceNpMatching2", + "libSceGnmDebugModuleReset": "libSceGnmDriver", + "libSceGnmDebugReset": "libSceGnmDriver", + "libSceGnmDriverCompat": "libSceGnmDriver", + "libSceGnmDriverResourceRegistration": "libSceGnmDriver", + "libSceGnmGetGpuCoreClockFrequency": "libSceGnmDriver", + "libSceGnmWaitFreeSubmit": "libSceGnmDriver", + "libSceLibcInternalExt": "libSceLibcInternal", + "libSceJson2": "libSceJson", + "libSceDbgKeyboard": "libSceKeyboard", + "libSceNpAppLauncher": "libSceNpGameIntent", + "libSceNetDebug": "libSceNet", + "libSceAppMessaging": "libSceSystemService", + "libSceLncUtil": "libSceSystemService", + "libSceShellCoreUtil": "libSceSystemService", + "libSceSystemService_jvm": "libSceSystemService", + "libSceSystemServiceActivateHevc": "libSceSystemService", + "libSceSystemServiceActivateHevcSoft": "libSceSystemService", + "libSceSystemServiceActivateMpeg2": "libSceSystemService", + "libSceSystemServiceAppLaunchLink": "libSceSystemService", + "libSceSystemServiceClosedCaption": "libSceSystemService", + "libSceSystemServiceDbg": "libSceSystemService", + "libSceSystemServiceEyeToEyeDistance": "libSceSystemService", + "libSceSystemServiceForShellCoreOnly": "libSceSystemService", + "libSceSystemServicePadspkRouting": "libSceSystemService", + "libSceSystemServicePartyVoice": "libSceSystemService", + "libSceSystemServicePlatformPrivacy": "libSceSystemService", + "libSceSystemServicePowerControl": "libSceSystemService", + "libSceSystemServicePowerSaveLevel": "libSceSystemService", + "libSceSystemServicePs2Emu": "libSceSystemService", + "libSceSystemServicePsmKit": "libSceSystemService", + "libSceSystemServiceStore": "libSceSystemService", + "libSceSystemServiceSuspend": "libSceSystemService", + "libSceSystemServiceTelemetry": "libSceSystemService", + "libSceSystemServiceTournamentMlg": "libSceSystemService", + "libSceSystemServiceUdsApp": "libSceSystemService", + "libSceSystemServiceVideoServiceWebApp": "libSceSystemService", + "libSceSystemServiceVideoToken": "libSceSystemService", + "libSceSystemServiceVoiceRecognition": "libSceSystemService", + "libSceSystemServiceWebApp": "libSceSystemService", + "libSceSystemServiceWebBrowser": "libSceSystemService", + "libSceSystemServiceYouTubeAccountLinkStatus": "libSceSystemService", + "libSceSystemStateMgr": "libSceSystemService", + "libSceNpFriendListDialogCompat": "libSceNpFriendListDialog", + "libSceNpScoreCompat": "libSceNpScore", + "libSceHmdDistortion": "libSceHmd", + "libsceHmdReprojectionMultilayer": "libSceHmd", + "libSceNpAuthCompat": "libSceNpAuth", + "libSceNpTusCompat": "libSceNpTus", + "libSceJpegDec_jvm": "libSceJpegDec", + "libSceNpUtilityCompat": "libSceNpUtility", + "libSceNetBwe": "libSceNetCtl", + "libSceNetCtlAp": "libSceNetCtl", + "libSceNetCtlApIpcInt": "libSceNetCtl", + "libSceNetCtlForNpToolkit": "libSceNetCtl", + "libSceNetCtlV6": "libSceNetCtl", + "libSceDeviceService": "libSceMbus", + "libSceMbusDebug": "libSceMbus", + "libSceOrbisCompatForVideoService": "libSceOrbisCompat", + "libSceWebSecurity": "libSceOrbisCompat", + "libSceNpWebApi2AsyncRestricted": "libSceNpWebApi2", + "libSceAudioDeviceControl": "libSceAudioOut", + "libSceAudioOutDeviceService": "libSceAudioOut", + "libSceAudioOutSparkControl": "libSceAudioOut", + "libSceDbgAudioOut": "libSceAudioOut", + "libSceNpProfileDialogCompat": "libSceNpProfileDialog", + "libSceDbgPlayGo": "libScePlayGo", + "libSceWebKit2ForVideoService": "libSceWebKit2", + "libSceGLSlimServerVSH": "libSceSlimGLVSH", + "libSceScreenShotDrc": "libSceScreenShot", + "libSceNpSns": "libSceNpManager", + "libSceNpSnsTwitch": "libSceNpManager", + "libSceNpSnsYouTube": "libSceNpManager", + "libSceNpSnsTwitchDialog": "libSceNpSnsDialog", + "libSceNpWebApiCompat": "libSceNpWebApi", + "libSceUsbStorageAux": "libSceUsbStorage", + "libSceContentBinder": "libSceContentSearch", + "libSceInvitationDialogCompat": "libSceInvitationDialog", + "libSceNpPartyCompat": "libSceNpParty", + "libSceNpSignalingCompat": "libSceNpSignaling", + "libc_setjmp": "libc", + "libSceAsyncStorageInternalAux": "libSceAsyncStorageInternal", + "libSceAppContent": "libSceAppContentUtil", + "libSceAppContentBundle": "libSceAppContentUtil", + "libSceAppContentIro": "libSceAppContentUtil", + "libSceAppContentPft": "libSceAppContentUtil", + "libSceAppContentSc": "libSceAppContentUtil", + "libSceDbgVideoOut": "libSceVideoOut", + "libSceDbgVideoOutSub4k": "libSceVideoOut", + "libSceVideoOutAniso": "libSceVideoOut", + "libSceVideoOutBaseMode4k": "libSceVideoOut", + "libSceVideoOutExtra": "libSceVideoOut", + "libSceVideoOutHdr": "libSceVideoOut", + "libSceVideoOutRawEdid": "libSceVideoOut", + "libSceVideoOutWindow2Pre400": "libSceVideoOut", + "libSceSharePlayCompat": "libSceSharePlay", + "libScePngDec_jvm": "libScePngDec", + "libSceAvSettingDebug": "libSceAvSetting", + "libSceGameLiveStreaming_debug": "libSceGameLiveStreaming", + "libSceGameLiveStreaming_direct_streaming": "libSceGameLiveStreaming", + "libSceGameLiveStreamingCompat": "libSceGameLiveStreaming", + "libSceVrTrackerDeviceRejection": "libSceVrTracker", + "libSceVrTrackerFourDeviceAllowed": "libSceVrTracker", + "libSceVrTrackerGpuTest": "libSceVrTracker", + "libSceVrTrackerLiveCapture": "libSceVrTracker", + "libSceNpCommonCompat": "libSceNpCommon", +} From ced84c2de4abb632f29a50e84ed937815fd3d91d Mon Sep 17 00:00:00 2001 From: ac2pic Date: Sat, 25 Jun 2022 19:34:22 -0500 Subject: [PATCH 3/7] Bug fixes --- pkg/oelf/OELFGenDynlibData.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index 8f3c045..86323a2 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -211,7 +211,7 @@ func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPat for _, library := range orbisElf.LibrarySymbolDictionary.Keys() { libNa := library.(string) if !contains(orbisElf.ModuleList, libNa) { - rolsd.Set(libNa, orbisElf.LibraryModuleDictionary.Get(libNa)) + rolsd.Set(libNa, []string{}) } } @@ -534,14 +534,19 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { } for idx, library := range libraries { - libSyms := orbisElf.LibrarySymbolDictionary.Get(library).([]string) - if contains(libSyms, symbol.Name) { - libraryName = library.(string) + libName := library.(string) + libSyms := orbisElf.LibrarySymbolDictionary.Get(libName) + if libSyms == nil { + continue + } + if contains(libSyms.([]string), symbol.Name) { + libraryName = libName symbolLibraryIndex = idx break } } + if symbolLibraryIndex < 0 { return 0, errors.New(fmt.Sprintf("missing library for symbol (%s)", symbol.Name)) } @@ -559,7 +564,7 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { } // TODO: Comment out when not debugging - fmt.Printf("[%s;] %s: %d %s: %d \n", symbol.Name, moduleName, symbolModuleIndex, libraryName, symbolLibraryIndex) + // fmt.Printf("[%s;] %s: %d %s: %d \n", symbol.Name, moduleName, symbolModuleIndex, libraryName, symbolLibraryIndex) // Build the NID and insert it into the table nidTableBuff.WriteString(buildNIDEntry(symbol.Name, 1+symbolLibraryIndex, 1+symbolModuleIndex)) From 056bf65e64ff6d4d2240ece9860eed61138379b6 Mon Sep 17 00:00:00 2001 From: ac2pic Date: Sat, 25 Jun 2022 19:43:48 -0500 Subject: [PATCH 4/7] Bug fixes --- pkg/oelf/OELFGenDynlibData.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index 86323a2..7ad3987 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -204,7 +204,7 @@ func (orbisElf *OrbisElf) GenerateLibrarySymbolDictionary(sdkPath string, libPat var rolsd = NewOrderedMap() for _, module := range orbisElf.ModuleList { - rolsd.Set(module, orbisElf.LibrarySymbolDictionary.Get(module)) + rolsd.Set(module, []string{}) } From f0100df2ace80b3b8e90e3ff1c0da22786c0d099 Mon Sep 17 00:00:00 2001 From: ac2pic Date: Sat, 25 Jun 2022 19:46:03 -0500 Subject: [PATCH 5/7] Add minor refactor --- pkg/oelf/OELFGenDynlibData.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index 7ad3987..c4e8aea 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -535,11 +535,8 @@ func writeNIDTable(orbisElf *OrbisElf, segmentData *[]byte) (uint64, error) { for idx, library := range libraries { libName := library.(string) - libSyms := orbisElf.LibrarySymbolDictionary.Get(libName) - if libSyms == nil { - continue - } - if contains(libSyms.([]string), symbol.Name) { + libSyms := orbisElf.LibrarySymbolDictionary.Get(libName).([]string) + if contains(libSyms, symbol.Name) { libraryName = libName symbolLibraryIndex = idx break From d2040c93bc2771b0550d7019afbfcc2a3ef60866 Mon Sep 17 00:00:00 2001 From: ac2pic Date: Sat, 25 Jun 2022 20:47:36 -0500 Subject: [PATCH 6/7] Bug fix --- pkg/oelf/OELFGenDynlibData.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index c4e8aea..40fa68d 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -610,7 +610,7 @@ func buildNIDEntry(symbolName string, libraryId int, moduleId int) string { libraryIdChar := string(_indexEncodingTable[libraryId]) moduleIdChar := string(_indexEncodingTable[moduleId]) - nid += "#" + moduleIdChar + "#" + libraryIdChar + "\x00" + nid += "#" + libraryIdChar + "#" + moduleIdChar + "\x00" return nid } From 40a745dca421f774a04810a6d61406968afd566f Mon Sep 17 00:00:00 2001 From: ac2pic Date: Fri, 8 Jul 2022 18:58:17 -0500 Subject: [PATCH 7/7] Bug fix --- pkg/oelf/OELFGenDynlibData.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/oelf/OELFGenDynlibData.go b/pkg/oelf/OELFGenDynlibData.go index 40fa68d..c49440f 100644 --- a/pkg/oelf/OELFGenDynlibData.go +++ b/pkg/oelf/OELFGenDynlibData.go @@ -422,7 +422,7 @@ func writeModuleTable(moduleList []string, librarySymbolDictionary *OrderedMap, moduleOffset := uint64(len(moduleTableBuff.Bytes())) + 1 - _importedModuleOffsets = append(_importedLibraryOffsets, moduleOffset) + _importedModuleOffsets = append(_importedModuleOffsets, moduleOffset) // Assume library name is module name too _importedLibraryOffsets = append(_importedLibraryOffsets, moduleOffset)