Check-in [5bcf07f30f]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some minor tweaks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256:5bcf07f30f6fa51efaecf2c9056d1ec9f5c18e5b2ca81256c3a226a51c4dd44c
User & Date: kc5tja 2018-01-29 08:41:48
Context
2018-01-29
08:41
Some minor tweaks Leaf check-in: 5bcf07f30f user: kc5tja tags: trunk
00:31
Find a DYN ELF file, process a handful of program header entries, locate string table and symbol table, and attempt to "relocate" the PLT. (It just prints out stuff that it would do if it were doing it for realz). Holy hell this is fucking complex. WWAAAAAAAYY more complex than Amiga hunk format. And for what? I just don't see the benefit of any of this. check-in: b67cec6988 user: kc5tja tags: trunk
Changes

Changes to lab/lab.c.

108
109
110
111
112
113
114


115
116
117
118
119
120
121
...
209
210
211
212
213
214
215




216
217
218


219
220
221
222
223
224
225
226
	printf("    Number of tags alloted: %ld\n", phdr[i].p_filesz / sizeof(Elf64_Dyn));
	printf("    (Number actually used may be less.)\n");

	/*
	 * To resolve DT_NEEDED entries, which lists library dependencies
	 * for this module, wherein we'd recursively load an ELF module if
	 * we were for real, we first need to resolve the DT_STRTAB entry.


	 */

	stringTable = 0;
	symbolTable = NULL;
	for(
		tag = taglist, i = 0;
		i < ntags;
................................................................................
	if(!dt_jmprel && !pltRelocType && !pltRelocSize) {
		printf("      NO PLT RELOCATIONS.\n");
	}
	else if(pltRelocType == DT_REL) {
		Elf64_Rel *pltRelocations = (Elf64_Rel *)((char *)lc->elfBlob + dt_jmprel);
		printf("      PLT REL Relocations at %p\n", pltRelocations);
		while(pltRelocSize) {




			printf(
				"        Relocation at %p of type %08lX\n",
				pltRelocations->r_offset + lc->elfBlob,


				pltRelocations->r_info
			);
			pltRelocSize -= sizeof(Elf64_Rel);
			pltRelocations++;
		}
	}
	else if(pltRelocType == DT_RELA) {
		Elf64_Rela *pltRelocations = (Elf64_Rela *)((char *)lc->elfBlob + dt_jmprel);







>
>







 







>
>
>
>

|

>
>
|







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
	printf("    Number of tags alloted: %ld\n", phdr[i].p_filesz / sizeof(Elf64_Dyn));
	printf("    (Number actually used may be less.)\n");

	/*
	 * To resolve DT_NEEDED entries, which lists library dependencies
	 * for this module, wherein we'd recursively load an ELF module if
	 * we were for real, we first need to resolve the DT_STRTAB entry.
	 * Since we'll need it later for symbol resolution anyway, we also
	 * capture the symbol table here too.
	 */

	stringTable = 0;
	symbolTable = NULL;
	for(
		tag = taglist, i = 0;
		i < ntags;
................................................................................
	if(!dt_jmprel && !pltRelocType && !pltRelocSize) {
		printf("      NO PLT RELOCATIONS.\n");
	}
	else if(pltRelocType == DT_REL) {
		Elf64_Rel *pltRelocations = (Elf64_Rel *)((char *)lc->elfBlob + dt_jmprel);
		printf("      PLT REL Relocations at %p\n", pltRelocations);
		while(pltRelocSize) {
			int symbolKey = (int)ELF64_R_SYM(pltRelocations->r_info);
			int relocationType = (int)ELF64_R_TYPE(pltRelocations->r_info);
			Elf64_Sym *symbol = &symbolTable[symbolKey];

			printf(
				"        Relocation at %p of symbol %d (%s) of type %d\n",
				pltRelocations->r_offset + lc->elfBlob,
				symbolKey,
				symbol->st_name ? stringTable + symbol->st_name : "<anonymous>",
				relocationType
			);
			pltRelocSize -= sizeof(Elf64_Rel);
			pltRelocations++;
		}
	}
	else if(pltRelocType == DT_RELA) {
		Elf64_Rela *pltRelocations = (Elf64_Rela *)((char *)lc->elfBlob + dt_jmprel);