History

win64: update tiny_impdef, tiny_libmaker (Elf64)

grischka committed 17 years ago

Commit 06aed3d1 parent 09ac9fa2 files · +146 −385Browse files

Unified · Split

2 files
  1. win32/tools/tiny_impdef.c +121 −280
  2. win32/tools/tiny_libmaker.c +25 −105
win32/tools/tiny_impdef.c+121−280
@@ -23,201 +23,92 @@ · 22 unmodified lines
2323 #define WIN32_LEAN_AND_MEAN
2424 #include <windows.h>
2525 #include <stdio.h>
26+#include <malloc.h>
27+#include "../../config.h"
2628
27−/* Offset to PE file signature */
28−#define NTSIGNATURE(a) ((LPVOID)((BYTE *)a + \
29− ((PIMAGE_DOS_HEADER)a)->e_lfanew))
30−
31−/* MS-OS header identifies the NT PEFile signature dword;
32− the PEFILE header exists just after that dword. */
33−#define PEFHDROFFSET(a) ((LPVOID)((BYTE *)a + \
34− ((PIMAGE_DOS_HEADER)a)->e_lfanew + \
35− SIZE_OF_NT_SIGNATURE))
36−
37−/* PE optional header is immediately after PEFile header. */
38−#define OPTHDROFFSET(a) ((LPVOID)((BYTE *)a + \
39− ((PIMAGE_DOS_HEADER)a)->e_lfanew + \
40− SIZE_OF_NT_SIGNATURE + \
41− sizeof (IMAGE_FILE_HEADER)))
42−
43−/* Section headers are immediately after PE optional header. */
44−#define SECHDROFFSET(a) ((LPVOID)((BYTE *)a + \
45− ((PIMAGE_DOS_HEADER)a)->e_lfanew + \
46− SIZE_OF_NT_SIGNATURE + \
47− sizeof (IMAGE_FILE_HEADER) + \
48− sizeof (IMAGE_OPTIONAL_HEADER)))
49−
50−
51−#define SIZE_OF_NT_SIGNATURE 4
52−
53−/* -------------------------------------------------------------- */
54−
55−int WINAPI NumOfSections (
56− LPVOID lpFile)
29+int read_mem(FILE *fp, unsigned offset, void *buffer, unsigned len)
5730 {
58− /* Number of sections is indicated in file header. */
59− return (int)
60− ((PIMAGE_FILE_HEADER)
61− PEFHDROFFSET(lpFile))->NumberOfSections;
31+ fseek(fp, offset, 0);
32+ return len == fread(buffer, 1, len, fp);
6233 }
6334
64−
65−/* -------------------------------------------------------------- */
66−
67−LPVOID WINAPI ImageDirectoryOffset (
68− LPVOID lpFile,
69− DWORD dwIMAGE_DIRECTORY)
35+char *get_export_names(FILE *fp)
7036 {
71− PIMAGE_OPTIONAL_HEADER poh;
72− PIMAGE_SECTION_HEADER psh;
73− int nSections = NumOfSections (lpFile);
74− int i = 0;
75− LPVOID VAImageDir;
76−
77− /* Retrieve offsets to optional and section headers. */
78− poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile);
79− psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile);
80−
81− /* Must be 0 thru (NumberOfRvaAndSizes-1). */
82− if (dwIMAGE_DIRECTORY >= poh->NumberOfRvaAndSizes)
83− return NULL;
84−
85− /* Locate image directory's relative virtual address. */
86− VAImageDir = (LPVOID)poh->DataDirectory[dwIMAGE_DIRECTORY].VirtualAddress;
87−
88− /* Locate section containing image directory. */
89− while (i++<nSections)
90− {
91− if (psh->VirtualAddress <= (DWORD)VAImageDir
92− && psh->VirtualAddress + psh->SizeOfRawData > (DWORD)VAImageDir)
93− break;
94− psh++;
95− }
96−
97− if (i > nSections)
98− return NULL;
99−
100− /* Return image import directory offset. */
101− return (LPVOID)(((int)lpFile +
102− (int)VAImageDir - psh->VirtualAddress) +
103− (int)psh->PointerToRawData);
104−}
37+ int l, i, n, n0;
38+ char *p;
10539
106−/* -------------------------------------------------------------- */
40+ IMAGE_SECTION_HEADER ish;
41+ IMAGE_EXPORT_DIRECTORY ied;
42+ IMAGE_DOS_HEADER dh;
43+ IMAGE_FILE_HEADER ih;
44+ DWORD sig, ref, addr, ptr, namep;
45+#ifdef TCC_TARGET_X86_64
46+ IMAGE_OPTIONAL_HEADER64 oh;
47+ const int MACHINE = 0x8664;
48+#else
49+ IMAGE_OPTIONAL_HEADER32 oh;
50+ const int MACHINE = 0x014C;
51+#endif
52+ int pef_hdroffset, opt_hdroffset, sec_hdroffset;
53+
54+ n = n0 = 0;
55+ p = NULL;
56+
57+ if (!read_mem(fp, 0, &dh, sizeof dh))
58+ goto the_end;
59+ if (!read_mem(fp, dh.e_lfanew, &sig, sizeof sig))
60+ goto the_end;
61+ if (sig != 0x00004550)
62+ goto the_end;
63+ pef_hdroffset = dh.e_lfanew + sizeof sig;
64+ if (!read_mem(fp, pef_hdroffset, &ih, sizeof ih))
65+ goto the_end;
66+ if (MACHINE != ih.Machine)
67+ goto the_end;
68+ opt_hdroffset = pef_hdroffset + sizeof ih;
69+ sec_hdroffset = opt_hdroffset + sizeof oh;
70+ if (!read_mem(fp, opt_hdroffset, &oh, sizeof oh))
71+ goto the_end;
10772
108−BOOL WINAPI GetSectionHdrByName (
109− LPVOID lpFile,
110− IMAGE_SECTION_HEADER *sh,
111− char *szSection)
112−{
113− PIMAGE_SECTION_HEADER psh;
114− int nSections = NumOfSections (lpFile);
115− int i;
73+ if (IMAGE_DIRECTORY_ENTRY_EXPORT >= oh.NumberOfRvaAndSizes)
74+ goto the_end;
11675
117− if ((psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile)) != NULL)
118− {
119− /* find the section by name */
120− for (i=0; i<nSections; i++)
121− {
122− if (!strcmp (psh->Name, szSection))
123− {
124− /* copy data to header */
125− memcpy ((LPVOID)sh, (LPVOID)psh, sizeof (IMAGE_SECTION_HEADER));
126− return TRUE;
127− }
128− else
129− psh++;
130− }
76+ addr = oh.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
77+ //printf("addr: %08x\n", addr);
78+ for (i = 0; i < ih.NumberOfSections; ++i) {
79+ if (!read_mem(fp, sec_hdroffset + i * sizeof ish, &ish, sizeof ish))
80+ goto the_end;
81+ //printf("vaddr: %08x\n", ish.VirtualAddress);
82+ if (addr >= ish.VirtualAddress && addr < ish.VirtualAddress + ish.SizeOfRawData)
83+ goto found;
13184 }
132− return FALSE;
133−}
85+ goto the_end;
13486
135−/* -------------------------------------------------------------- */
136−
137−BOOL WINAPI GetSectionHdrByAddress (
138− LPVOID lpFile,
139− IMAGE_SECTION_HEADER *sh,
140− DWORD addr)
141−{
142− PIMAGE_SECTION_HEADER psh;
143− int nSections = NumOfSections (lpFile);
144− int i;
87+found:
88+ ref = ish.VirtualAddress - ish.PointerToRawData;
89+ if (!read_mem(fp, addr - ref, &ied, sizeof ied))
90+ goto the_end;
14591
146− if ((psh = (PIMAGE_SECTION_HEADER)SECHDROFFSET (lpFile)) != NULL)
147− {
148− /* find the section by name */
149− for (i=0; i<nSections; i++)
150− {
151− if (addr >= psh->VirtualAddress
152− && addr < psh->VirtualAddress + psh->SizeOfRawData)
153− {
154− /* copy data to header */
155− memcpy ((LPVOID)sh, (LPVOID)psh, sizeof (IMAGE_SECTION_HEADER));
156− return TRUE;
92+ namep = ied.AddressOfNames - ref;
93+ for (i = 0; i < ied.NumberOfNames; ++i) {
94+ if (!read_mem(fp, namep, &ptr, sizeof ptr))
95+ goto the_end;
96+ namep += sizeof ptr;
97+ for (l = 0;;) {
98+ if (n+1 >= n0)
99+ p = realloc(p, n0 = n0 ? n0 * 2 : 256);
100+ if (!read_mem(fp, ptr - ref + l, p + n, 1) || ++l >= 80) {
101+ free(p), p = NULL;
102+ goto the_end;
157103 }
158− else
159− psh++;
160− }
161− }
162− return FALSE;
163−}
164−
165−/* -------------------------------------------------------------- */
166−
167−int WINAPI GetExportFunctionNames (
168− LPVOID lpFile,
169− HANDLE hHeap,
170− char **pszFunctions)
171−{
172− IMAGE_SECTION_HEADER sh;
173− PIMAGE_EXPORT_DIRECTORY ped;
174− int *pNames, *pCnt;
175− char *pSrc, *pDest;
176− int i, nCnt;
177− DWORD VAImageDir;
178− PIMAGE_OPTIONAL_HEADER poh;
179− char *pOffset;
180−
181− /* Get section header and pointer to data directory
182− for .edata section. */
183− if (NULL == (ped = (PIMAGE_EXPORT_DIRECTORY)
184− ImageDirectoryOffset (lpFile, IMAGE_DIRECTORY_ENTRY_EXPORT)))
185− return 0;
186−
187− poh = (PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET (lpFile);
188− VAImageDir = poh->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
189−
190− if (FALSE == GetSectionHdrByAddress (lpFile, &sh, VAImageDir))
191− return 0;
192−
193− pOffset = (char *)lpFile + (sh.PointerToRawData - sh.VirtualAddress);
194−
195− pNames = (int *)(pOffset + (DWORD)ped->AddressOfNames);
196−
197− /* Figure out how much memory to allocate for all strings. */
198− nCnt = 1;
199− for (i=0, pCnt = pNames; i<(int)ped->NumberOfNames; i++)
200− {
201− pSrc = (pOffset + *pCnt++);
202− if (pSrc)
203− nCnt += strlen(pSrc)+1;
204− }
205−
206− /* Allocate memory off heap for function names. */
207− pDest = *pszFunctions = HeapAlloc (hHeap, HEAP_ZERO_MEMORY, nCnt);
208−
209− /* Copy all strings to buffer. */
210− for (i=0, pCnt = pNames; i<(int)ped->NumberOfNames; i++)
211− {
212− pSrc = (pOffset + *pCnt++);
213− if (pSrc) {
214− strcpy(pDest, pSrc);
215− pDest += strlen(pSrc)+1;
104+ if (p[n++] == 0)
105+ break;
216106 }
217107 }
218− *pDest = 0;
219−
220− return ped->NumberOfNames;
108+ if (p)
109+ p[n] = 0;
110+the_end:
111+ return p;
221112 }
222113
223114 /* -------------------------------------------------------------- */
@@ -238,61 +129,49 @@ static char *file_basename(const char *name) · 14 unmodified lines
238129
239130 int main(int argc, char **argv)
240131 {
241− HANDLE hHeap;
242− HANDLE hFile;
243− HANDLE hMapObject;
244− VOID *pMem;
245−
246− int nCnt, ret, n;
247− char *pNames;
132+ int ret, v, i;
248133 char infile[MAX_PATH];
249− char buffer[MAX_PATH];
250134 char outfile[MAX_PATH];
251− FILE *op;
252− char *p;
253135
254− hHeap = NULL;
255− hFile = NULL;
256− hMapObject = NULL;
257− pMem = NULL;
136+ static const char *ext[] = { ".dll", ".exe", NULL };
137+ const char *file, **pp;
138+ char path[MAX_PATH], *p, *q;
139+ FILE *fp, *op;
140+
258141 infile[0] = 0;
259142 outfile[0] = 0;
143+ fp = op = NULL;
144+ v = 0;
260145 ret = 1;
261146
262− for (n = 1; n < argc; ++n)
263− {
264− const char *a = argv[n];
147+ for (i = 1; i < argc; ++i) {
148+ const char *a = argv[i];
265149 if ('-' == a[0]) {
266− if (0 == strcmp(a, "-o")) {
267− if (++n == argc)
150+ if (0 == strcmp(a, "-v")) {
151+ v = 1;
152+ } else if (0 == strcmp(a, "-o")) {
153+ if (++i == argc)
268154 goto usage;
269− strcpy(outfile, argv[n]);
270− }
271− else
155+ strcpy(outfile, argv[i]);
156+ } else
272157 goto usage;
273−
274158 } else if (0 == infile[0])
275159 strcpy(infile, a);
276160 else
277161 goto usage;
278162 }
279163
280− if (0 == infile[0])
281− {
164+ if (0 == infile[0]) {
282165 usage:
283166 fprintf(stderr,
284− "tiny_impdef creates an export definition file (.def) from a dll\n"
167+ "tiny_impdef: create export definition file (.def) from a dll\n"
285168 "Usage: tiny_impdef library.dll [-o outputfile]\n"
286169 );
287170 goto the_end;
288171 }
289172
290− if (SearchPath(NULL, infile, ".dll", sizeof buffer, buffer, NULL))
291− strcpy(infile, buffer);
292−
293173 if (0 == outfile[0])
294174 {
295− char *p;
296175 strcpy(outfile, file_basename(infile));
297176 p = strrchr(outfile, '.');
298177 if (NULL == p)
@@ -300,93 +179,55 @@ usage: · 1 unmodified line
300179 strcpy(p, ".def");
301180 }
302181
303− hFile = CreateFile(
304− infile,
305− GENERIC_READ,
306− FILE_SHARE_READ,
307− NULL,
308− OPEN_EXISTING,
309− 0,
310− NULL
311− );
182+ file = infile;
183+#ifdef _WIN32
184+ for (pp = ext; *pp; ++pp)
185+ if (SearchPath(NULL, file, *pp, sizeof path, path, NULL)) {
186+ file = path;
187+ break;
188+ }
189+#endif
312190
313− if (hFile == INVALID_HANDLE_VALUE)
314− {
315− fprintf(stderr, "No such file: %s\n", infile);
191+ fp = fopen(file, "rb");
192+ if (NULL == fp) {
193+ fprintf(stderr, "tiny_impdef: no such file: %s\n", infile);
316194 goto the_end;
317195 }
318196
319−
320− hMapObject = CreateFileMapping(
321− hFile,
322− NULL,
323− PAGE_READONLY,
324− 0, 0,
325− NULL
326− );
327−
328− if (NULL == hMapObject)
329− {
330− fprintf(stderr, "Could not create file mapping: %s\n", infile);
197+ op = fopen(outfile, "w");
198+ if (NULL == op) {
199+ fprintf(stderr, "tiny_impdef: could not create output file: %s\n", outfile);
331200 goto the_end;
332201 }
333202
334− pMem = MapViewOfFile(
335− hMapObject, // object to map view of
336− FILE_MAP_READ, // read access
337− 0, // high offset: map from
338− 0, // low offset: beginning
339− 0); // default: map entire file
203+ if (v)
204+ printf("--> %s\n", infile);
340205
341− if (NULL == pMem)
342− {
343− fprintf(stderr, "Could not map view of file: %s\n", infile);
206+ fprintf(op, "LIBRARY %s\n\nEXPORTS\n", file_basename(infile));
207+ p = get_export_names(fp);
208+ if (NULL == p) {
209+ fprintf(stderr, "tiny_impdef: could not get exported function names.\n");
344210 goto the_end;
345211 }
346212
347− if (0 != strncmp(NTSIGNATURE(pMem), "PE", 2))
348− {
349− fprintf(stderr, "Not a PE file: %s\n", infile);
350− goto the_end;
213+ for (q = p, i = 0; *q; ++i) {
214+ fprintf(op, "%s\n", q);
215+ q += strlen(q) + 1;
351216 }
217+ free(p);
352218
353−
354− hHeap = GetProcessHeap();
355− nCnt = GetExportFunctionNames(pMem, hHeap, &pNames);
356− if (0 == nCnt) {
357− fprintf(stderr, "Could not get exported function names: %s\n", infile);
358− goto the_end;
219+ if (v) {
220+ printf("<-- %s\n", outfile);
221+ printf("%d symbol(s) found\n", i);
359222 }
360223
361− printf("--> %s\n", infile);
362−
363− op = fopen(outfile, "w");
364− if (NULL == op)
365− {
366− fprintf(stderr, "Could not create file: %s\n", outfile);
367− goto the_end;
368− }
369−
370− printf("<-- %s\n", outfile);
371−
372− fprintf(op, "LIBRARY %s\n\nEXPORTS\n", file_basename(infile));
373− for (n = 0, p = pNames; n < nCnt; ++n)
374− {
375− fprintf(op, "%s\n", p);
376− while (*p++);
377− }
378224 ret = 0;
379225
380226 the_end:
381− if (pMem)
382− UnmapViewOfFile(pMem);
383−
384− if (hMapObject)
385− CloseHandle(hMapObject);
386−
387− if (hFile)
388− CloseHandle(hFile);
389−
227+ if (fp)
228+ fclose(fp);
229+ if (op)
230+ fclose(op);
390231 return ret;
391232 }
392233
win32/tools/tiny_libmaker.c+25−105
@@ -13,98 +13,8 @@ · 12 unmodified lines
1313 #include <io.h> /* for mktemp */
1414 #endif
1515
16−/* #include "ar-elf.h" */
17−/* "ar-elf.h" */
18−/* ELF_v1.2.pdf */
19−typedef unsigned short int Elf32_Half;
20−typedef int Elf32_Sword;
21−typedef unsigned int Elf32_Word;
22−typedef unsigned int Elf32_Addr;
23−typedef unsigned int Elf32_Off;
24−typedef unsigned short int Elf32_Section;
25−
26−#define EI_NIDENT 16
27−typedef struct {
28− unsigned char e_ident[EI_NIDENT];
29− Elf32_Half e_type;
30− Elf32_Half e_machine;
31− Elf32_Word e_version;
32− Elf32_Addr e_entry;
33− Elf32_Off e_phoff;
34− Elf32_Off e_shoff;
35− Elf32_Word e_flags;
36− Elf32_Half e_ehsize;
37− Elf32_Half e_phentsize;
38− Elf32_Half e_phnum;
39− Elf32_Half e_shentsize;
40− Elf32_Half e_shnum;
41− Elf32_Half e_shstrndx;
42−} Elf32_Ehdr;
43−
44−typedef struct {
45− Elf32_Word sh_name;
46− Elf32_Word sh_type;
47− Elf32_Word sh_flags;
48− Elf32_Addr sh_addr;
49− Elf32_Off sh_offset;
50− Elf32_Word sh_size;
51− Elf32_Word sh_link;
52− Elf32_Word sh_info;
53− Elf32_Word sh_addralign;
54− Elf32_Word sh_entsize;
55−} Elf32_Shdr;
56−
57−#define SHT_NULL 0
58−#define SHT_PROGBITS 1
59−#define SHT_SYMTAB 2
60−#define SHT_STRTAB 3
61−#define SHT_RELA 4
62−#define SHT_HASH 5
63−#define SHT_DYNAMIC 6
64−#define SHT_NOTE 7
65−#define SHT_NOBITS 8
66−#define SHT_REL 9
67−#define SHT_SHLIB 10
68−#define SHT_DYNSYM 11
69−
70−typedef struct {
71− Elf32_Word st_name;
72− Elf32_Addr st_value;
73− Elf32_Word st_size;
74− unsigned char st_info;
75− unsigned char st_other;
76− Elf32_Half st_shndx;
77−} Elf32_Sym;
78−
79−#define ELF32_ST_BIND(i) ((i)>>4)
80−#define ELF32_ST_TYPE(i) ((i)&0xf)
81−#define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
82−
83−#define STT_NOTYPE 0
84−#define STT_OBJECT 1
85−#define STT_FUNC 2
86−#define STT_SECTION 3
87−#define STT_FILE 4
88−#define STT_LOPROC 13
89−#define STT_HIPROC 15
90−
91−#define STB_LOCAL 0
92−#define STB_GLOBAL 1
93−#define STB_WEAK 2
94−#define STB_LOPROC 13
95−#define STB_HIPROC 15
96−
97−typedef struct {
98− Elf32_Word p_type;
99− Elf32_Off p_offset;
100− Elf32_Addr p_vaddr;
101− Elf32_Addr p_paddr;
102− Elf32_Word p_filesz;
103− Elf32_Word p_memsz;
104− Elf32_Word p_flags;
105− Elf32_Word p_align;
106−} Elf32_Phdr;
107−/* "ar-elf.h" ends */
16+#include "../../config.h"
17+#include "../../elf.h"
10818
10919 #define ARMAG "!<arch>\n"
11020 #define ARFMAG "`\n"
@@ -119,7 +29,6 @@ typedef struct ArHdr { · 8 unmodified lines
11929 char ar_fmag[2];
12030 } ArHdr;
12131
122−
12332 unsigned long le2belong(unsigned long ul) {
12433 return ((ul & 0xFF0000)>>8)+((ul & 0xFF000000)>>24) +
12534 ((ul & 0xFF)<<24)+((ul & 0xFF00)<<8);
@@ -148,9 +57,9 @@ ArHdr arhdro = { · 22 unmodified lines
14857 int main(int argc, char **argv)
14958 {
15059 FILE *fi, *fh, *fo;
151− Elf32_Ehdr *ehdr;
152− Elf32_Shdr *shdr;
153− Elf32_Sym *sym;
60+ ElfW(Ehdr) *ehdr;
61+ ElfW(Shdr) *shdr;
62+ ElfW(Sym) *sym;
15463 int i, fsize, iarg;
15564 char *buf, *shstr, *symtab = NULL, *strtab = NULL;
15665 int symtabsize = 0, strtabsize = 0;
@@ -207,7 +116,7 @@ int main(int argc, char **argv) · 50 unmodified lines
207116 }
208117 if ((fi = fopen(argv[iarg], "rb")) == NULL)
209118 {
210− fprintf(stderr, "Can't open file %s \n", argv[iarg]);
119+ fprintf(stderr, "Can't open file %s \n", argv[iarg]);
211120 remove(tfile);
212121 return 2;
213122 }
@@ -218,14 +127,21 @@ int main(int argc, char **argv) · 4 unmodified lines
218127 fread(buf, fsize, 1, fi);
219128 fclose(fi);
220129
221− printf("%s:\n", argv[iarg]);
130+ //printf("%s:\n", argv[iarg]);
222131 // elf header
223− ehdr = (Elf32_Ehdr *)buf;
224− shdr = (Elf32_Shdr *) (buf + ehdr->e_shoff + ehdr->e_shstrndx * ehdr->e_shentsize);
132+ ehdr = (ElfW(Ehdr) *)buf;
133+ if (ehdr->e_ident[4] != TCC_ELFCLASS)
134+ {
135+ fprintf(stderr, "Unsupported Elf Class: %s\n", argv[iarg]);
136+ remove(tfile);
137+ return 2;
138+ }
139+
140+ shdr = (ElfW(Shdr) *) (buf + ehdr->e_shoff + ehdr->e_shstrndx * ehdr->e_shentsize);
225141 shstr = (char *)(buf + shdr->sh_offset);
226142 for (i = 0; i < ehdr->e_shnum; i++)
227143 {
228− shdr = (Elf32_Shdr *) (buf + ehdr->e_shoff + i * ehdr->e_shentsize);
144+ shdr = (ElfW(Shdr) *) (buf + ehdr->e_shoff + i * ehdr->e_shentsize);
229145 if (!shdr->sh_offset) continue;
230146 if (shdr->sh_type == SHT_SYMTAB)
231147 {
@@ -244,12 +160,16 @@ int main(int argc, char **argv) · 12 unmodified lines
244160
245161 if (symtab && symtabsize)
246162 {
247− int nsym = symtabsize / sizeof(Elf32_Sym);
163+ int nsym = symtabsize / sizeof(ElfW(Sym));
248164 //printf("symtab: info size shndx name\n");
249165 for (i = 1; i < nsym; i++)
250166 {
251− sym = (Elf32_Sym *) (symtab + i * sizeof(Elf32_Sym));
252− if (sym->st_shndx && (sym->st_info == 0x11 || sym->st_info == 0x12)) {
167+ sym = (ElfW(Sym) *) (symtab + i * sizeof(ElfW(Sym)));
168+ if (sym->st_shndx &&
169+ (sym->st_info == 0x10
170+ || sym->st_info == 0x11
171+ || sym->st_info == 0x12
172+ )) {
253173 //printf("symtab: %2Xh %4Xh %2Xh %s\n", sym->st_info, sym->st_size, sym->st_shndx, strtab + sym->st_name);
254174 istrlen = strlen(strtab + sym->st_name)+1;
255175 anames = realloc(anames, strpos+istrlen);
@@ -281,7 +201,7 @@ int main(int argc, char **argv) · 25 unmodified lines
281201 } else fpos = 0;
282202 // write header
283203 fwrite("!<arch>\n", 8, 1, fh);
284− sprintf(stmp, "%-10d", strpos + (funccnt+1) * sizeof(int));
204+ sprintf(stmp, "%-10d", (int)(strpos + (funccnt+1) * sizeof(int)));
285205 memcpy(&arhdr.ar_size, stmp, 10);
286206 fwrite(&arhdr, sizeof(arhdr), 1, fh);
287207 afpos[0] = le2belong(funccnt);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t