_bfd_generic_mkarchive (abfd)
bfd *abfd;
{
- abfd->tdata =(PTR) zalloc (sizeof (struct artdata));
+ abfd->tdata = bfd_zalloc(abfd, sizeof (struct artdata));
if (abfd->tdata == NULL) {
bfd_error = no_memory;
return false;
}
-bfd_ardata(abfd)->cache = 0;
+ bfd_ardata(abfd)->cache = 0;
return true;
}
bfd *arch_bfd, *new_elt;
file_ptr filepos;
{
- struct ar_cache *new_cache = ((struct ar_cache *)
- zalloc (sizeof (struct ar_cache)));
+ struct ar_cache *new_cache = ((struct ar_cache *)bfd_zalloc(arch_bfd,sizeof (struct ar_cache)));
if (new_cache == NULL) {
bfd_error = no_memory;
allocsize += namelen + 1;
}
- allocptr = zalloc (allocsize);
+ allocptr = bfd_zalloc(abfd, allocsize);
if (allocptr == NULL) {
bfd_error = no_memory;
return NULL;
n_nfd = _bfd_create_empty_archive_element_shell (archive);
if (n_nfd == NULL) {
- free (new_areldata);
return NULL;
}
n_nfd->origin = bfd_tell (archive);
return n_nfd;
/* huh? */
- free (new_areldata);
- free (n_nfd);
return NULL;
}
if (strncmp (armag, ARMAG, SARMAG)) return 0;
#endif
- bfd_set_ardata(abfd, (struct artdata *) zalloc (sizeof (struct artdata)));
+ bfd_set_ardata(abfd, (struct artdata *) bfd_zalloc(abfd,sizeof (struct artdata)));
if (bfd_ardata (abfd) == NULL) {
bfd_error = no_memory;
bfd_ardata (abfd)->first_file_filepos = SARMAG;
if (!BFD_SEND (abfd, _bfd_slurp_armap, (abfd))) {
- free (bfd_ardata (abfd));
+ bfd_release(abfd, bfd_ardata (abfd));
abfd->tdata = NULL;
return 0;
}
/* armap could be left ungc'd! FIXME -- potential storage leak */
if (!BFD_SEND (abfd, _bfd_slurp_extended_name_table, (abfd))) {
- free (bfd_ardata (abfd));
+ bfd_release(abfd, bfd_ardata (abfd));
abfd->tdata = NULL;
return 0;
}
mapdata = snarf_ar_hdr (abfd);
if (mapdata == NULL) return false;
- raw_armap = (int *) zalloc (mapdata->parsed_size);
+ raw_armap = (int *) bfd_zalloc(abfd,mapdata->parsed_size);
if (raw_armap == NULL) {
bfd_error = no_memory;
byebye:
- free (mapdata);
return false;
}
if (bfd_read ((PTR)raw_armap, 1, mapdata->parsed_size, abfd) !=
mapdata->parsed_size) {
bfd_error = malformed_archive;
- free (raw_armap);
goto byebye;
}
ardata->first_file_filepos = bfd_tell (abfd);
/* Pad to an even boundary if you have to */
ardata->first_file_filepos += (ardata-> first_file_filepos) %2;
- free (mapdata);
bfd_has_map (abfd) = true;
}
return true;
mapdata = snarf_ar_hdr (abfd);
if (mapdata == NULL) return false;
- raw_armap = (int *) zalloc (mapdata->parsed_size);
+ raw_armap = (int *) bfd_alloc(abfd,mapdata->parsed_size);
if (raw_armap == NULL) {
bfd_error = no_memory;
byebye:
- free (mapdata);
+
return false;
}
mapdata->parsed_size) {
bfd_error = malformed_archive;
oops:
- free (raw_armap);
+
goto byebye;
}
unsigned int carsym_size = (nsymz * sizeof (carsym));
unsigned int ptrsize = (4 * nsymz);
unsigned int i;
- ardata->symdefs = (carsym *) zalloc (carsym_size + stringsize + 1);
+ ardata->symdefs = (carsym *) bfd_zalloc(abfd,carsym_size + stringsize + 1);
if (ardata->symdefs == NULL) {
bfd_error = no_memory;
goto oops;
ardata->first_file_filepos = bfd_tell (abfd);
/* Pad to an even boundary if you have to */
ardata->first_file_filepos += (ardata->first_file_filepos) %2;
- free (raw_armap);
- free (mapdata);
+
bfd_has_map (abfd) = true;
return true;
}
if (namedata == NULL) return false;
- bfd_ardata (abfd)->extended_names = zalloc (namedata->parsed_size);
+ bfd_ardata (abfd)->extended_names = bfd_zalloc(abfd,namedata->parsed_size);
if (bfd_ardata (abfd)->extended_names == NULL) {
bfd_error = no_memory;
byebye:
- free (namedata);
+
return false;
}
if (bfd_read ((PTR)bfd_ardata (abfd)->extended_names, 1,
namedata->parsed_size, abfd) != namedata->parsed_size) {
bfd_error = malformed_archive;
- free (bfd_ardata (abfd)->extended_names);
+
bfd_ardata (abfd)->extended_names = NULL;
goto byebye;
}
bfd_ardata (abfd)->first_file_filepos +=
(bfd_ardata (abfd)->first_file_filepos) %2;
- free (namedata);
+
}
return true;
}
if (total_namelen == 0) return true;
- *tabloc = zalloc (total_namelen);
+ *tabloc = bfd_zalloc (abfd,total_namelen);
if (*tabloc == NULL) {
bfd_error = no_memory;
return false;
*/
struct areltdata *
-bfd_ar_hdr_from_filesystem (filename)
- char *filename;
+DEFUN(bfd_ar_hdr_from_filesystem, (abfd,filename),
+ bfd* abfd AND
+ CONST char *filename)
{
struct stat status;
struct areltdata *ared;
return NULL;
}
- ared = (struct areltdata *) zalloc (sizeof (struct ar_hdr) +
+ ared = (struct areltdata *) bfd_zalloc(abfd, sizeof (struct ar_hdr) +
sizeof (struct areltdata));
if (ared == NULL) {
bfd_error = no_memory;
}
struct ar_hdr *
-bfd_special_undocumented_glue (filename)
- char *filename;
+DEFUN(bfd_special_undocumented_glue, (abfd, filename),
+ bfd *abfd AND
+ char *filename)
{
- return (struct ar_hdr *) bfd_ar_hdr_from_filesystem (filename) -> arch_header;
+ return (struct ar_hdr *) bfd_ar_hdr_from_filesystem (abfd, filename) -> arch_header;
}
}
if (!current->arelt_data) {
current->arelt_data =
- (PTR) bfd_ar_hdr_from_filesystem (current->filename);
+ (PTR) bfd_ar_hdr_from_filesystem (arch, current->filename);
if (!current->arelt_data) return false;
/* Put in the file name */
if (makemap && hasobjects) {
if (compute_and_write_armap (arch, elength) != true) {
- if (etable) free (etable);
return false;
}
}
bfd_write (&hdr, 1, sizeof (struct ar_hdr), arch);
bfd_write (etable, 1, elength, arch);
if ((elength % 2) == 1) bfd_write ("\n", 1, 1, arch);
- if (etable) free (etable);
+
}
for (current = arch->archive_head; current; current = current->next) {
if (elength != 0) elength += sizeof (struct ar_hdr);
elength += elength %2 ;
- map = (struct orl *) zalloc (orl_max * sizeof (struct orl));
+ map = (struct orl *) bfd_zalloc (arch,orl_max * sizeof (struct orl));
if (map == NULL) {
bfd_error = no_memory;
return false;
storage = get_symtab_upper_bound (current);
if (storage != 0) {
- syms = (asymbol **) zalloc (storage);
+ syms = (asymbol **) bfd_zalloc (arch,storage);
if (syms == NULL) {
bfd_error = no_memory; /* FIXME -- memory leak */
return false;
if (orl_count == orl_max)
{
orl_max *= 2;
- map = (struct orl *) realloc ((char *) map,
+ map = (struct orl *) bfd_realloc (arch, (char *) map,
orl_max * sizeof (struct orl));
}
/* OK, now we have collected all the data, let's write them out */
if (!BFD_SEND (arch, write_armap,
(arch, elength, map, orl_count, stridx))) {
- free (map);
+
return false;
}
- free (map);
+
return true;
}
SCRIPTS = ld-gld68k.script ld-gld68k-Ur.script ld-gld68k-r.script \
ld-gld.script ld-gld-Ur.script ld-gld-r.script ld-lnk960.script \
- ld-lnk960-r.script ld-gld960.script
+ ld-lnk960-r.script ld-gld960.script \
+ ld-gldm88kbcs.script ld-gldm88kbcs-Ur.script ld-gldm88kbcs-r.script
PROCESSED_SCRIPTS = ld-gld68k.x ld-gld68k-Ur.x ld-gld68k-r.x ld-gld.x \
- ld-gld-Ur.x ld-gld-r.x ld-lnk960.x ld-lnk960-r.x ld-gld960.x
+ ld-gld-Ur.x ld-gld-r.x ld-lnk960.x ld-lnk960-r.x ld-gld960.x \
+ ld-gldm88kbcs.x ld-gldm88kbcs-Ur.x ld-gldm88kbcs-r.x
#### target and host dependent Makefile fragments come in here.
###
-CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES)
+CFLAGS = $(INCLUDES) $(DEBUG) $(HDEFINES) $(TDEFINES) $(CDEFINES)
LINTFLAGS = $(INCLUDES) $(EXTRA_DEF)
.SUFFIXES: .y .x .script $(SUFFIXES)
BFDLIB=$(srcdir)/../bfd$(subdir)/libbfd.a
OFILES= ldgram.o ldlex.o ldlang.o ldmain.o ldwrite.o ldexp.o ld-lnk960.o ld-gld68k.o \
+ ld-gldm88kbcs.o \
ld-gld.o ld-gld960.o ld-emul.o ldversion.o ldmisc.o ldsym.o ld-vanilla.o ldfile.o
HEADERS=config.h ldmain.h ldmain.h ldmisc.h ldsym.h ldlang.h ldexp.h \
MANSOURCES=ld.tex
LDCSOURCES=ldlang.c ldmain.c ldwrite.c ld-lnk960.c ld-gld.c ld-gld68k.c \
+ ld-gldm88kbcs.c \
ld-gld960.c ld-emul.c ldversion.c ldmisc.c ldexp.c ldsym.c ldfile.c ld-vanilla.c
GENERATED_SOURCES=ldgram.tab.c ldlex.c ldgram.tab.h y.tab.h
ld-gld68k.o: $(PROCESSED_SCRIPTS) ld-gld68k.c
ld-gld960.o: $(PROCESSED_SCRIPTS) ld-gld960.c
+ld-gldm88kbcs.o: $(PROCESSED_SCRIPTS) ld-gldm88kbcs.c
ld-emul.o: ld-emul.c
ld-vanilla.o: ld-vanilla.c
ld-lnk960.o: $(PROCESSED_SCRIPTS) ld-lnk960.c
/* If in there look for the strings: */
#define GLD_EMULATION_NAME "gld"
#define VANILLA_EMULATION_NAME "vanilla"
+#define GLDM88KBCS_EMULATION_NAME "gldm88kbcs"
#define GLD68K_EMULATION_NAME "gld68k"
#define GLD960_EMULATION_NAME "gld960"
#define LNK960_EMULATION_NAME "lnk960"
#define LNK960_TARGET "coff-Intel-big"
#define GLD960_TARGET "b.out.big"
#define VANILLA_TARGET "a.out-generic-big"
-
+#define GLDM88KBCS_TARGET "m88kbcs"
#include "ldmisc.h"
extern ld_emulation_xfer_type ld_lnk960_emulation;
+extern ld_emulation_xfer_type ld_gldm88kbcs_emulation;
extern ld_emulation_xfer_type ld_gld_emulation;
extern ld_emulation_xfer_type ld_vanilla_emulation;
extern ld_emulation_xfer_type ld_gld68k_emulation;
else if (strcmp(target,GLD960_EMULATION_NAME)==0) {
ld_emulation = &ld_gld960_emulation;
}
+else if (strcmp(target,GLDM88KBCS_EMULATION_NAME)==0) {
+ ld_emulation = &ld_gldm88kbcs_emulation;
+}
#ifndef GNU960
else if (strcmp(target,GLD_EMULATION_NAME)==0) {
ld_emulation = &ld_gld_emulation;
ldfile_add_library_path("/lib");
ldfile_add_library_path("/usr/lib");
ldfile_add_library_path("/usr/local/lib/lib");
- ldfile_output_architecture = bfd_arch_sparc;
}
gld_set_output_arch()
{
/* Set the output architecture and machine if possible */
- unsigned long machine = 0;
- bfd_set_arch_mach(output_bfd, ldfile_output_architecture, machine);
+ bfd_set_arch_mach(output_bfd, ldfile_output_architecture, ldfile_output_machine);
}
static char *
-
+OUTPUT_ARCH(sparc)
+OUTPUT_FORMAT("a.out-generic-big")
SEARCH_DIR(/lib)
SEARCH_DIR(/usr/lib)
SEARCH_DIR(/usr/local/lib)
sdef->section->vma : 0));
}
else {
- result = new_rel(sdef->value, os);
+ result = new_rel(sdef->value + sdef->section->output_offset, os);
}
}
}
}
#endif
+
+/* Set the output architecture */
+void
+DEFUN(ldfile_set_output_arch,(string),
+CONST char *string)
+{
+ enum bfd_architecture arch;
+ unsigned long machine;
+ if (bfd_scan_arch_mach(string, &arch, &machine) == true) {
+ ldfile_output_architecture = arch;
+ ldfile_output_machine = machine;
+ ldfile_output_machine_name = string;
+ }
+ else {
+ info("%P%F: Can't represent machine `%s'\n", string);
+ }
+}
boolean force_make_executable = false;
boolean ldgram_in_script = false;
-boolean ldgram_in_defsym = false;
boolean ldgram_had_equals = false;
/* LOCALS */
%token <name> NAME
%type <integer> length
-%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
+%right <token> PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ
%right <token> '?' ':'
%left <token> OROR
%left <token> ANDAND
%token <token> ALIGN_K BLOCK LONG SHORT BYTE
%token SECTIONS
%token '{' '}'
-%token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION
+%token ALIGNMENT SIZEOF_HEADERS OUTPUT_FORMAT FORCE_COMMON_ALLOCATION OUTPUT_ARCH
%token NEXT SIZEOF ADDR SCRIPT ENDSCRIPT
%token MEMORY
%token DSECT NOLOAD COPY INFO OVERLAY
%token OPTION_e OPTION_c OPTION_noinhibit_exec OPTION_s OPTION_S
%token OPTION_format OPTION_F OPTION_u
-%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X
-%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT OPTION_defsym
+%token OPTION_d OPTION_dc OPTION_dp OPTION_x OPTION_X OPTION_defsym
+%token OPTION_v OPTION_M OPTION_t STARTUP HLL SYSLIB FLOAT NOFLOAT
%token OPTION_n OPTION_r OPTION_o OPTION_b OPTION_A OPTION_R
%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
%token OPTION_Ur
;
command_line_option:
- SCRIPT
+ '{'
{ ldgram_in_script = true; }
ifile_list
{ ldgram_in_script = false; }
- ENDSCRIPT
+ '}'
| OPTION_v
{
ldversion();
}
| OPTION_defsym
{
- ldgram_in_defsym = true;
- ldgram_had_equals = false;
}
NAME '='
exp_head
{
lang_add_assignment(exp_assop($4,$3,$5));
- ldgram_in_defsym = false;
}
| '-' NAME
{ info("%P%F Unrecognised option -%s\n", $2); }
script_file:
{ ldgram_in_script = true; }
- ifile_list ENDSCRIPT
+ ifile_list '}'
{ ldgram_in_script = false; }
;
{ lang_add_output($3); }
| OUTPUT_FORMAT '(' NAME ')'
{ lang_add_output_format($3); }
+ | OUTPUT_ARCH '(' NAME ')'
+ { ldfile_set_output_arch($3); }
| FORCE_COMMON_ALLOCATION
{ command_line.force_common_definition = true ; }
| INPUT '(' input_list ')'
else {
printf("%s", abfd->filename);
}
+ printf("(%d bytes)", bfd_alloc_size(abfd));
print_nl();
/* Find all the symbols in this file defined in this section */
{
output_target = format;
}
+
lang_output_section_statement_lookup,(CONST char * CONST name));
PROTO(void, ldlang_add_undef,(CONST char *CONST name));
-
+PROTO(void, lang_add_output_format,(CONST char *));
int debug;
-extern boolean ldgram_in_defsym;
+static boolean ldgram_in_defsym;
static boolean ldgram_had_equals;
extern boolean ldgram_in_script;
static char *command_line;
"FILL",FILL,
"STARTUP",STARTUP,
"OUTPUT_FORMAT",OUTPUT_FORMAT,
+"OUTPUT_ARCH", OUTPUT_ARCH,
"HLL",HLL,
"SYSLIB",SYSLIB,
"FLOAT",FLOAT,
ldlex_input_stack = (FILE *)NULL;
ldfile_input_filename = (char *)NULL;
/* First char after script eof is a @ so that we can tell the grammer
- that we've eft */
+ that we've left */
thischar = '@';
}
%%
-"@" { return ENDSCRIPT; }
-"\ -defsym\ " { return OPTION_defsym; }
+"@" { return '}'; }
+"\ -defsym\ " { ldgram_in_defsym = true; return OPTION_defsym; }
"\ -noinhibit_exec\ " { return OPTION_noinhibit_exec; }
"\ -format\ " { return OPTION_format; }
"\ -n\ " { return OPTION_n; }
"\ -r\ " { return OPTION_r; }
+"\ -i\ " { return OPTION_r; }
"\ -Ur\ " { return OPTION_Ur; }
"\ -o\ " { return OPTION_o; }
"\ -g\ " { return OPTION_g; }
"\ -u\ " { return OPTION_u; }
"\ -s\ " { return OPTION_s; }
"\ -S\ " { return OPTION_S; }
+"\ -B{FILENAME}\ " { /* Ignored */ }
"\ -l"{FILENAME} {
yylval.name = buystring(yytext+3);
return OPTION_l;
return OPTION_Aarch;
}
-" " { if (ldgram_had_equals == true) ldgram_in_defsym = false; }
+" " {
+ if (ldgram_had_equals == true) {
+ ldgram_in_defsym = false;
+ ldgram_had_equals = false;
+ }
+ }
"<<=" { RTOKEN(LSHIFTEQ);}
">>=" { RTOKEN(RSHIFTEQ);}
"||" { RTOKEN(OROR);}
}
}
-
+ if(ldgram_in_script == true) {
+ switch (ch) {
+ case '*':
+ case '=':
+ case '+':
+ case '-':
+ case '!':
+ case '~':
+ goto quit;
+ }
+ }
+
if (isalpha(ch) || isdigit(ch) || ch == '.' || ch == '_' ||
ch == '/' || ch == '.' || ch == '+' || ch == '-' || ch =='=') {
yytext[yyleng++] = ch;
int ch;
ch = getchar();
printf("/* Generated through mkscript */\n");
- printf("\"SCRIPT \\\n");
+ printf("\"{ \\\n");
while (ch != EOF) {
- if (ch == '\n') {
+ if (ch == '\"') {
+ putchar('\\');
+ putchar('\"');
+ }
+else { if (ch == '\n') {
putchar(' ');
putchar('\\');
}
putchar(ch);
+ }
ch = getchar();
}
- printf("ENDSCRIPT\"\n");
+ printf("}\"\n");
return 0;
}