Dump linux vDSO symbols
This commit is contained in:
		
							parent
							
								
									ad9db42aa4
								
							
						
					
					
						commit
						3582376f35
					
				| @ -12,9 +12,9 @@ if [ ! -d "depot_tools" ]; then | ||||
| fi | ||||
| 
 | ||||
| if [ ! -d "src" ]; then | ||||
|   ./depot_tools/fetch --nohooks breakpad | ||||
|   PYTHONDONTWRITEBYTECODE=1 python2.7 ./depot_tools/fetch.py --nohooks breakpad | ||||
| else | ||||
|   ./depot_tools/gclient sync --nohooks | ||||
|   PYTHONDONTWRITEBYTECODE=1 python2.7 ./depot_tools/gclient.py sync --nohooks | ||||
| fi | ||||
| 
 | ||||
| if [ ! -d "build" ]; then | ||||
|  | ||||
| @ -487,6 +487,35 @@ class UploadThread: public IThread | ||||
| #if defined _LINUX | ||||
| 	bool UploadSymbolFile(const google_breakpad::CodeModule *module, const char *presubmitToken) { | ||||
| 		auto debugFile = module->debug_file(); | ||||
| 		std::string vdsoOutputPath = ""; | ||||
| 
 | ||||
| 		if (debugFile == "linux-gate.so") { | ||||
| 			char vdsoOutputPathBuffer[512]; | ||||
| 			g_pSM->BuildPath(Path_SM, vdsoOutputPathBuffer, sizeof(vdsoOutputPathBuffer), "data/dumps/linux-gate.so"); | ||||
| 			vdsoOutputPath = vdsoOutputPathBuffer; | ||||
| 			int auxvStart = 0; | ||||
| 			while (environ[auxvStart++] != nullptr); | ||||
| 			struct { | ||||
| 				int id; | ||||
| 				void *value; | ||||
| 			} *auxvEntry = (decltype(auxvEntry))&environ[auxvStart]; | ||||
| 			for (int auxvIndex = 0; true; ++auxvIndex) { | ||||
| 				if (auxvEntry[auxvIndex].id == 0) break; | ||||
| 				if (auxvEntry[auxvIndex].id != 33) continue; // AT_SYSINFO_EHDR
 | ||||
| 				Elf32_Ehdr *vdsoHdr = (Elf32_Ehdr *)auxvEntry[auxvIndex].value; | ||||
| 				auto vdsoSize = vdsoHdr->e_shoff + (vdsoHdr->e_shentsize * vdsoHdr->e_shnum); | ||||
| 				void *vdsoBuffer = malloc(vdsoSize); | ||||
| 				memcpy(vdsoBuffer, vdsoHdr, vdsoSize); | ||||
| 				FILE *vdsoFile = fopen(vdsoOutputPath.c_str(), "wb"); | ||||
| 				if (vdsoFile) { | ||||
| 					fwrite(vdsoBuffer, 1, vdsoSize, vdsoFile); | ||||
| 					fclose(vdsoFile); | ||||
| 					debugFile = vdsoOutputPath; | ||||
| 				} | ||||
| 				free(vdsoBuffer); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (debugFile[0] != '/') { | ||||
| 			return false; | ||||
| 		} | ||||
| @ -522,6 +551,10 @@ class UploadThread: public IThread | ||||
| 		// output = output.substr(0, output.find("\n"));
 | ||||
| 		// printf(">>> %s\n", output.c_str());
 | ||||
| 
 | ||||
| 		if (debugFile == vdsoOutputPath) { | ||||
| 			unlink(vdsoOutputPath.c_str()); | ||||
| 		} | ||||
| 
 | ||||
| 		IWebForm *form = webternet->CreateForm(); | ||||
| 
 | ||||
| 		const char *minidumpAccount = g_pSM->GetCoreConfigValue("MinidumpAccount"); | ||||
| @ -691,6 +724,10 @@ class UploadThread: public IThread | ||||
| 		const auto &codeFile = module->code_file(); | ||||
| 
 | ||||
| #ifndef WIN32 | ||||
| 		if (codeFile == "linux-gate.so") { | ||||
| 			return kMTSystem; | ||||
| 		} | ||||
| 
 | ||||
| 		if (codeFile[0] != '/') { | ||||
| #else | ||||
| 		if (codeFile[1] != ':') { | ||||
|  | ||||
| @ -237,6 +237,35 @@ int main(int argc, char *argv[]) | ||||
| 			auto module = processState.modules()->GetModuleAtIndex(moduleIndex); | ||||
| 
 | ||||
| 			auto debugFile = module->debug_file(); | ||||
| 			std::string vdsoOutputPath = ""; | ||||
| 
 | ||||
| 			if (debugFile == "linux-gate.so") { | ||||
| 				auto workingDir = getcwd(nullptr, 0); | ||||
| 				vdsoOutputPath = workingDir + std::string("/linux-gate.so"); | ||||
| 				int auxvStart = 0; | ||||
| 				while (environ[auxvStart++] != nullptr); | ||||
| 				struct { | ||||
| 					int id; | ||||
| 					void *value; | ||||
| 				} *auxvEntry = (decltype(auxvEntry))&environ[auxvStart]; | ||||
| 				for (int auxvIndex = 0; true; ++auxvIndex) { | ||||
| 					if (auxvEntry[auxvIndex].id == 0) break; | ||||
| 					if (auxvEntry[auxvIndex].id != 33) continue; // AT_SYSINFO_EHDR
 | ||||
| 					Elf32_Ehdr *vdsoHdr = (Elf32_Ehdr *)auxvEntry[auxvIndex].value; | ||||
| 					auto vdsoSize = vdsoHdr->e_shoff + (vdsoHdr->e_shentsize * vdsoHdr->e_shnum); | ||||
| 					void *vdsoBuffer = malloc(vdsoSize); | ||||
| 					memcpy(vdsoBuffer, vdsoHdr, vdsoSize); | ||||
| 					FILE *vdsoFile = fopen(vdsoOutputPath.c_str(), "wb"); | ||||
| 					if (vdsoFile) { | ||||
| 						fwrite(vdsoBuffer, 1, vdsoSize, vdsoFile); | ||||
| 						fclose(vdsoFile); | ||||
| 						debugFile = vdsoOutputPath; | ||||
| 					} | ||||
| 					free(vdsoBuffer); | ||||
| 				} | ||||
| 				free(workingDir); | ||||
| 			} | ||||
| 
 | ||||
| 			if (debugFile[0] != '/') { | ||||
| 				continue; | ||||
| 			} | ||||
| @ -272,6 +301,10 @@ int main(int argc, char *argv[]) | ||||
| 			auto output = outputStream.str(); | ||||
| 			output = output.substr(0, output.find("\n")); | ||||
| 			printf("%s\n", output.c_str()); | ||||
| 
 | ||||
| 			if (debugFile == vdsoOutputPath) { | ||||
| 				unlink(vdsoOutputPath.c_str()); | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user