projects
/
fw
/
sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* asranlib/asranlib.c, link/lkar.c: don't check the padding bytes since
[fw/sdcc]
/
as
/
asranlib
/
asranlib.c
diff --git
a/as/asranlib/asranlib.c
b/as/asranlib/asranlib.c
index ab13c6785b857739342ffda4c68af151f5d16f4d..237b1f946390335e3b6a2170eacab9720c5f730c 100644
(file)
--- a/
as/asranlib/asranlib.c
+++ b/
as/asranlib/asranlib.c
@@
-231,7
+231,7
@@
get_member_name_by_offset (FILE * fp, long offset)
struct symbol_s
{
const char *name;
struct symbol_s
{
const char *name;
-
off
_t offset;
+
size
_t offset;
struct symbol_s *next;
};
struct symbol_s *next;
};
@@
-362,12
+362,13
@@
enum_symbols (FILE * fp, long size, int (*func) (const char *sym, void *param),
static int
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
{
static int
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
{
+ long pos = ftell (fp);
+
if (print_index)
{
char *buf, *po, *ps;
int i;
long nsym;
if (print_index)
{
char *buf, *po, *ps;
int i;
long nsym;
- long pos;
printf ("Archive index:\n");
printf ("Archive index:\n");
@@
-379,8
+380,6
@@
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
return 0;
}
return 0;
}
- pos = ftell (fp);
-
nsym = sgetl (buf);
po = buf + 4;
nsym = sgetl (buf);
po = buf + 4;
@@
-393,13
+392,16
@@
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
offset = sgetl (po);
po += 4;
offset = sgetl (po);
po += 4;
- printf ("%s in ", ps);
- ps += strlen(ps) + 1;
-
obj = get_member_name_by_offset (fp, offset); /* member name */
obj = get_member_name_by_offset (fp, offset); /* member name */
- printf ("%s\n", obj);
+ printf ("%s in %s", ps, obj);
+ if (verbose)
+ printf (" at 0x%04x\n", offset);
+ else
+ putchar ('\n');
free (obj);
free (obj);
+ ps += strlen(ps) + 1;
+
}
free (buf);
}
free (buf);
@@
-407,11
+409,9
@@
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
putchar ('\n');
}
putchar ('\n');
}
- else
- {
- /* skip the symbol table */
- fseek (fp, hdr->ar_size + (hdr->ar_size & 1), SEEK_CUR);
- }
+
+ /* skip the symbol table */
+ fseek (fp, pos + hdr->ar_size + (hdr->ar_size & 1), SEEK_SET);
return 1;
}
return 1;
}
@@
-419,13
+419,14
@@
process_symbol_table (struct ar_hdr *hdr, FILE *fp)
static int
process_bsd_symbol_table (struct ar_hdr *hdr, FILE *fp)
{
static int
process_bsd_symbol_table (struct ar_hdr *hdr, FILE *fp)
{
+ long pos = ftell (fp);
+
if (print_index)
{
char *buf, *po, *ps;
int i;
long tablesize;
long nsym;
if (print_index)
{
char *buf, *po, *ps;
int i;
long tablesize;
long nsym;
- long pos;
printf ("Archive index:\n");
printf ("Archive index:\n");
@@
-437,8
+438,6
@@
process_bsd_symbol_table (struct ar_hdr *hdr, FILE *fp)
return 0;
}
return 0;
}
- pos = ftell (fp);
-
tablesize = sgetl (buf);
nsym = tablesize / 8;
tablesize = sgetl (buf);
nsym = tablesize / 8;
@@
-468,11
+467,9
@@
process_bsd_symbol_table (struct ar_hdr *hdr, FILE *fp)
putchar ('\n');
}
putchar ('\n');
}
- else
- {
- /* skip the symbol table */
- fseek (fp, hdr->ar_size + (hdr->ar_size & 1), SEEK_CUR);
- }
+
+ /* skip the symbol table */
+ fseek (fp, pos + hdr->ar_size + (hdr->ar_size & 1), SEEK_SET);
return 1;
}
return 1;
}
@@
-481,9
+478,10
@@
int
get_symbols (FILE * fp, const char *archive)
{
struct ar_hdr hdr;
get_symbols (FILE * fp, const char *archive)
{
struct ar_hdr hdr;
+ size_t hdr_len;
char *name;
char *name;
- if (!is_ar (fp) || !
ar_get_header (&hdr, fp, &name
))
+ if (!is_ar (fp) || !
(hdr_len = ar_get_header (&hdr, fp, &name)
))
{
fprintf (stderr, "asranlib: %s: File format not recognized\n", archive);
exit (1);
{
fprintf (stderr, "asranlib: %s: File format not recognized\n", archive);
exit (1);
@@
-494,7
+492,7
@@
get_symbols (FILE * fp, const char *archive)
free (name);
process_symbol_table (&hdr, fp);
free (name);
process_symbol_table (&hdr, fp);
- if (!
ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL
))
+ if (!
(hdr_len = ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL)
))
return 1;
}
else if (AR_IS_BSD_SYMBOL_TABLE (name))
return 1;
}
else if (AR_IS_BSD_SYMBOL_TABLE (name))
@@
-502,11
+500,13
@@
get_symbols (FILE * fp, const char *archive)
free (name);
process_bsd_symbol_table (&hdr, fp);
free (name);
process_bsd_symbol_table (&hdr, fp);
- if (!
ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL
))
+ if (!
(hdr_len = ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL)
))
return 1;
}
return 1;
}
+ else if (!verbose && !list)
+ free (name);
- first_member_offset = ftell (fp) -
ARHDR_LEN
;
+ first_member_offset = ftell (fp) -
hdr_len
;
/* walk trough all archive members */
do
/* walk trough all archive members */
do
@@
-523,17
+523,11
@@
get_symbols (FILE * fp, const char *archive)
{
long mdule_offset = ftell (fp);
{
long mdule_offset = ftell (fp);
- offset = mdule_offset -
ARHDR_LEN
;
+ offset = mdule_offset -
hdr_len
;
enum_symbols (fp, hdr.ar_size, add_symbol, NULL);
enum_symbols (fp, hdr.ar_size, add_symbol, NULL);
- fseek (fp, mdule_offset + hdr.ar_size, SEEK_SET);
-
- if (hdr.ar_size & 1)
- {
- int c = getc (fp);
- assert (c == EOF || c == '\n');
- }
+ fseek (fp, mdule_offset + hdr.ar_size + (hdr.ar_size & 1), SEEK_SET);
}
if (verbose)
}
if (verbose)
@@
-551,7
+545,7
@@
get_symbols (FILE * fp, const char *archive)
fseek (fp, hdr.ar_size + (hdr.ar_size & 1), SEEK_CUR);
}
}
fseek (fp, hdr.ar_size + (hdr.ar_size & 1), SEEK_CUR);
}
}
- while (
ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL
));
+ while (
(hdr_len = ar_get_header (&hdr, fp, (verbose || list) ? &name : NULL)
));
return 1;
}
return 1;
}