Modifed to care about semi colons again, newlines are ignored - sorry

Per.
This commit is contained in:
Steve Chamberlain 1992-03-02 22:22:59 +00:00
parent 4ef09e3613
commit 76971f0da2
9 changed files with 82 additions and 91 deletions

View File

@ -14,7 +14,7 @@ SECTIONS
{ {
.text : { .text : {
*(.text) *(.text)
${RELOCATING+ __etext = .} ${RELOCATING+ __etext = .};
*(.lit) *(.lit)
*(.shdata) *(.shdata)
} ${RELOCATING+ > text} } ${RELOCATING+ > text}
@ -24,13 +24,13 @@ SECTIONS
.talias : { } ${RELOCATING+ > talias} .talias : { } ${RELOCATING+ > talias}
.data : { .data : {
*(.data) *(.data)
${RELOCATING+ __edata = .} ${RELOCATING+ __edata = .};
} ${RELOCATING+ > data} } ${RELOCATING+ > data}
.bss SIZEOF(.data) + ADDR(.data) : .bss SIZEOF(.data) + ADDR(.data) :
{ {
*(.bss) *(.bss)
*(COMMON) *(COMMON)
${RELOCATING+ __end = ALIGN(0x8)} ${RELOCATING+ __end = ALIGN(0x8)};
} }
.mstack : { } ${RELOCATING+ > mstack} .mstack : { } ${RELOCATING+ > mstack}
.rstack : { } ${RELOCATING+ > rstack} .rstack : { } ${RELOCATING+ > rstack}

View File

@ -22,8 +22,8 @@ SECTIONS
{ {
*(.bss) *(.bss)
*(COMMON) *(COMMON)
${RELOCATING+_end = .} ${RELOCATING+_end = . };
${RELOCATING+__end = .} ${RELOCATING+__end = . };
} }
} }
EOF EOF

View File

@ -6,7 +6,7 @@ SECTIONS {
.text ${RELOCATING+${TEXT_START_ADDR}} : .text ${RELOCATING+${TEXT_START_ADDR}} :
{ {
*(.text); *(.text);
${RELOCATING+_etext = .} ${RELOCATING+_etext = .};
} }
data ${RELOCATING+0x80002000} : data ${RELOCATING+0x80002000} :
{ {
@ -21,7 +21,7 @@ SECTIONS {
{ {
*(COMMON) *(COMMON)
*(.bss); *(.bss);
${RELOCATING+_end = .;} ${RELOCATING+_end = .};
} }
} }
EOF EOF

View File

@ -1,11 +1,12 @@
cat <<EOF cat <<EOF
OUTPUT_FORMAT(${OUTPUT_FORMAT}) OUTPUT_FORMAT("${OUTPUT_FORMAT}")
OUTPUT_ARCH(${ARCH}) OUTPUT_ARCH(${ARCH})
MEMORY { MEMORY {
rom : o = 0x0000, l = 0x7fe0 rom : o = 0x0000, l = 0x7fe0
duart : o = 0x7fe0, l = 16 duart : o = 0x7fe0, l = 16
ram : o = 0x8000, l = 29k ram : o = 0x8000, l = 28k
topram: o = 0x8000+28k, l = 1k
hmsram: o = 0xfb80, l = 512 hmsram: o = 0xfb80, l = 512
} }
@ -15,17 +16,27 @@ SECTIONS
{ {
*(.text) *(.text)
*(.strings) *(.strings)
_etext = .;
} ${RELOCATING+ > ram} } ${RELOCATING+ > ram}
.data : .data :
{ {
*(.data) *(.data)
_edata = .;
} ${RELOCATING+ > ram} } ${RELOCATING+ > ram}
.bss : .bss :
{ {
${RELOCATING+ _bss_start = .} ${RELOCATING+ _bss_start = .};
*(.bss) *(.bss)
*(COMMON) *(COMMON)
${RELOCATING+ _end = .} ${RELOCATING+ _end = .};
} ${RELOCATING+ >ram} } ${RELOCATING+ >ram}
.stack :
{
*(.stack)
} ${RELOCATING+ > topram}
} }
EOF EOF

View File

@ -1,7 +1,7 @@
EMULATION_NAME=h8300hms EMULATION_NAME=h8300hms
SCRIPT_NAME=h8300hms SCRIPT_NAME=h8300hms
OUTPUT_FORMAT="coff-h8300" OUTPUT_FORMAT="coff-h8300"
TEXT_START_ADDR=?? TEXT_START_ADDR=0x8000
PAGE_SIZE=?? PAGE_SIZE=128
ARCH=h8300 ARCH=h8300
TEMPLATE_NAME=h8300hms TEMPLATE_NAME=h8300hms

View File

@ -5,19 +5,19 @@ SECTIONS
{ {
${GLD_STYLE+ CREATE_OBJECT_SYMBOLS} ${GLD_STYLE+ CREATE_OBJECT_SYMBOLS}
*(.text) *(.text)
${RELOCATING+ _etext = .} ${RELOCATING+ _etext = .};
} }
.data : .data :
{ {
*(.data) *(.data)
${RELOCATING+ _edata = .} ${RELOCATING+ _edata = .};
} }
.bss : .bss :
{ {
${RELOCATING+ _bss_start = .} ${RELOCATING+ _bss_start = .};
*(.bss) *(.bss)
*(COMMON) *(COMMON)
${RELOCATING+ _end = .} ${RELOCATING+ _end = .};
} }
} }
EOF EOF

View File

@ -50,7 +50,7 @@ extern ld_config_type config;
extern lang_input_statement_type *script_file; extern lang_input_statement_type *script_file;
extern unsigned int defined_global_sym_count; extern unsigned int defined_global_sym_count;
extern lang_output_section_statement_type *abs_output_section;
extern bfd_vma print_dot; extern bfd_vma print_dot;
@ -121,21 +121,20 @@ static void
DEFUN(make_abs,(ptr), DEFUN(make_abs,(ptr),
etree_value_type *ptr) etree_value_type *ptr)
{ {
if (ptr->section != (lang_output_section_statement_type *)NULL) {
asection *s = ptr->section->bfd_section; asection *s = ptr->section->bfd_section;
ptr->value += s->vma; ptr->value += s->vma;
ptr->section = (lang_output_section_statement_type *)NULL; ptr->section = abs_output_section;
}
} }
static static
DEFUN(etree_value_type new_abs,(value), DEFUN(etree_value_type new_abs,(value),
bfd_vma value) bfd_vma value)
{ {
etree_value_type new; etree_value_type new;
new.valid = true; new.valid = true;
new.section = (lang_output_section_statement_type *)NULL; new.section = abs_output_section;
new.value = value; new.value = value;
return new; return new;
} }
@ -189,9 +188,9 @@ DEFUN(etree_value_type
new.valid = true; new.valid = true;
new.value = value; new.value = value;
new.section = section; new.section = section;
if (new.section != (lang_output_section_statement_type *)NULL) {
new.value -= section->bfd_section->vma; new.value -= section->bfd_section->vma;
}
return new; return new;
} }
@ -216,8 +215,8 @@ DEFUN(fold_binary,(tree, current_section, allocation_done, dot, dotp),
/* If values are from different sections, or this is an */ /* If values are from different sections, or this is an */
/* absolute expression, make both source args absolute */ /* absolute expression, make both source args absolute */
if (result.section != other.section || if (result.section != other.section ||
current_section == (lang_output_section_statement_type *)NULL) { current_section == abs_output_section)
{
make_abs(&result); make_abs(&result);
make_abs(&other); make_abs(&other);
} }
@ -230,13 +229,13 @@ DEFUN(fold_binary,(tree, current_section, allocation_done, dot, dotp),
if (other.value == 0) { if (other.value == 0) {
einfo("%F%S % by zero\n"); einfo("%F%S % by zero\n");
} }
result.value %= other.value; result.value = (int)result.value % (int)other.value;
break; break;
case '/': case '/':
if (other.value == 0) { if (other.value == 0) {
einfo("%F%S / by zero\n"); einfo("%F%S / by zero\n");
} }
result.value /= other.value; result.value = (int)result.value / (int) other.value;
break; break;
#define BOP(x,y) case x : result.value = result.value y other.value;break; #define BOP(x,y) case x : result.value = result.value y other.value;break;
BOP('+',+); BOP('+',+);
@ -320,11 +319,14 @@ DEFUN(fold_name, (tree, current_section, allocation_done, dot),
if (sdefp) { if (sdefp) {
asymbol *sdef = *sdefp; asymbol *sdef = *sdefp;
#if 0
if (sdef->section == (asection *)NULL) { if (sdef->section == (asection *)NULL) {
/* This is an absolute symbol */ /* This is an absolute symbol */
result = new_abs(sdef->value); result = new_abs(sdef->value);
} }
else { else
#endif
{
lang_output_section_statement_type *os = lang_output_section_statement_type *os =
lang_output_section_statement_lookup( lang_output_section_statement_lookup(
sdef->section->output_section->name); sdef->section->output_section->name);
@ -334,8 +336,8 @@ DEFUN(fold_name, (tree, current_section, allocation_done, dot),
if (sdef->the_bfd->usrdata && if (sdef->the_bfd->usrdata &&
((lang_input_statement_type*)(sdef->the_bfd->usrdata))->just_syms_flag == true) ((lang_input_statement_type*)(sdef->the_bfd->usrdata))->just_syms_flag == true)
{ {
result = new_abs(sdef->value + (sdef->section ? result = new_abs(sdef->value +sdef->section->vma);
sdef->section->vma : 0));
} }
else { else {
result = new_rel(sdef->value + sdef->section->output_offset, os); result = new_rel(sdef->value + sdef->section->output_offset, os);
@ -519,36 +521,19 @@ DEFUN(exp_fold_tree,(tree, current_section, allocation_done,
else else
{ {
def_ptr = (asymbol **)ldmalloc((bfd_size_type)(sizeof(asymbol **))); def_ptr = (asymbol **)ldmalloc((bfd_size_type)(sizeof(asymbol **)));
def = (asymbol def = (asymbol *)bfd_make_empty_symbol(script_file->the_bfd);
*)bfd_make_empty_symbol(script_file->the_bfd);
def->flags = 0;
sy->sdefs_chain = def_ptr;
*def_ptr = def; *def_ptr = def;
} }
def->value = result.value; def->value = result.value;
if (result.section !=
(lang_output_section_statement_type *)NULL) {
if (current_section !=
(lang_output_section_statement_type *)NULL) {
def->section = result.section->bfd_section; def->section = result.section->bfd_section;
def->flags = BSF_GLOBAL | BSF_EXPORT; def->flags = BSF_GLOBAL | BSF_EXPORT;
}
else {
/* Force to absolute */
def->value += result.section->bfd_section->vma;
def->section = &bfd_abs_section;
def->flags = BSF_GLOBAL | BSF_EXPORT ;
}
}
else {
def->section = &bfd_abs_section;
def->flags = BSF_GLOBAL | BSF_EXPORT ;
}
def->udata = (PTR)NULL; def->udata = (PTR)NULL;
@ -597,7 +582,8 @@ DEFUN(exp_binop,(code, lhs, rhs),
value.binary.lhs = lhs; value.binary.lhs = lhs;
value.binary.rhs = rhs; value.binary.rhs = rhs;
value.type.node_class = etree_binary; value.type.node_class = etree_binary;
r = exp_fold_tree_no_dot(&value, (lang_output_section_statement_type *)NULL, r = exp_fold_tree_no_dot(&value,
abs_output_section,
lang_first_phase_enum ); lang_first_phase_enum );
if (r.valid) if (r.valid)
{ {
@ -669,8 +655,9 @@ DEFUN(exp_nameop,(code, name),
value.name.type.node_class = etree_name; value.name.type.node_class = etree_name;
r = exp_fold_tree_no_dot(&value,(lang_output_section_statement_type *)NULL, r = exp_fold_tree_no_dot(&value,
lang_first_phase_enum); (lang_output_section_statement_type *)NULL,
lang_first_phase_enum);
if (r.valid) { if (r.valid) {
return exp_intop(r.value); return exp_intop(r.value);
} }

View File

@ -87,7 +87,7 @@ boolean ldgram_had_equals = false;
char *name; char *name;
int token; int token;
union etree_union *etree; union etree_union *etree;
asection *section; struct sec *section;
struct lang_output_section_statement_struct *output_section_statement; struct lang_output_section_statement_struct *output_section_statement;
union lang_statement_union **statement_ptr; union lang_statement_union **statement_ptr;
int lineno; int lineno;
@ -142,7 +142,7 @@ boolean ldgram_had_equals = false;
%token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp %token <name> OPTION_l OPTION_L OPTION_T OPTION_Aarch OPTION_Tfile OPTION_Texp
%token OPTION_Ur %token OPTION_Ur
%token ORIGIN FILL OPTION_g %token ORIGIN FILL OPTION_g
%token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS %token LENGTH CREATE_OBJECT_SYMBOLS INPUT OUTPUT CONSTRUCTORS
%type <token> assign_op %type <token> assign_op
%type <name> filename %type <name> filename
@ -153,14 +153,12 @@ ld_config_type config;
%% %%
file: command_line { lang_final(); }; file: command_line { lang_final(); };
filename: filename:
NAME; NAME;
command_line: command_line:
command_line command_line_option command_line command_line_option
| |
@ -175,12 +173,12 @@ command_line_option:
| OPTION_Bstatic { } | OPTION_Bstatic { }
| OPTION_v | OPTION_v
{ {
ldversion(); ldversion(0);
option_v = true; option_v = true;
} }
| OPTION_V | OPTION_V
{ {
ldversion(); ldversion(1);
option_v = true; option_v = true;
} }
| OPTION_t { | OPTION_t {
@ -361,7 +359,7 @@ ifile_p1:
| low_level_library | low_level_library
| floating_point_support | floating_point_support
| statement_anywhere | statement_anywhere
| ';' | ';'
| TARGET_K '(' NAME ')' | TARGET_K '(' NAME ')'
{ lang_add_target($3); } { lang_add_target($3); }
| SEARCH_DIR '(' filename ')' | SEARCH_DIR '(' filename ')'
@ -392,12 +390,13 @@ input_list:
; ;
sections: sections:
SECTIONS '{'sec_or_group_p1 '}' SECTIONS '{'sec_or_group_p1 '}'
; ;
sec_or_group_p1: sec_or_group_p1:
sec_or_group_p1 section sec_or_group_p1 section
| sec_or_group_p1 statement_anywhere | sec_or_group_p1 statement_anywhere
| sec_or_group_p1
| |
; ;
@ -439,10 +438,11 @@ input_section_spec:
statement: statement:
statement assignment end statement assignment end
| statement ';'
| statement
| statement CREATE_OBJECT_SYMBOLS | statement CREATE_OBJECT_SYMBOLS
{ {
lang_add_attribute(lang_object_symbols_statement_enum); } lang_add_attribute(lang_object_symbols_statement_enum); }
| statement ';'
| statement CONSTRUCTORS | statement CONSTRUCTORS
{ {
lang_add_attribute(lang_constructors_statement_enum); } lang_add_attribute(lang_constructors_statement_enum); }
@ -506,7 +506,7 @@ assign_op:
; ;
end: ';' | ',' end: ';' | ','
; ;
@ -528,7 +528,7 @@ opt_comma:
memory: memory:
MEMORY '{' memory_spec memory_spec_list '}' MEMORY '{' memory_spec memory_spec_list '}'
; ;
memory_spec_list: memory_spec_list:
@ -613,7 +613,7 @@ floating_point_support:
exp : exp :
'-' exp %prec UNARY '-' exp %prec UNARY
{ $$ = exp_unop('-', $2); } { $$ = exp_unop('-', $2); }
| '(' exp ')' | '(' exp ')'
{ $$ = $2; } { $$ = $2; }
| NEXT '(' exp ')' %prec UNARY | NEXT '(' exp ')' %prec UNARY
{ $$ = exp_unop($1,$3); } { $$ = exp_unop($1,$3); }
@ -702,14 +702,7 @@ opt_type:
| { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } | { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
; ;
opt_things: opt_things: ;
{
}
;
opt_exp: opt_exp:
@ -719,7 +712,7 @@ opt_exp:
; ;
opt_block: opt_block:
BLOCK '(' exp ')' BLOCK '(' exp ')'
{ $$ = exp_get_value_int($3, { $$ = exp_get_value_int($3,
1L, 1L,
"block", "block",
@ -729,7 +722,7 @@ opt_block:
; ;
memspec_opt: memspec_opt:
'>' NAME '>' NAME
{ $$ = $2; } { $$ = $2; }
| { $$ = "*default*"; } | { $$ = "*default*"; }
; ;

View File

@ -10,32 +10,32 @@ SECTIONS
.text ${RELOCATING+ 0x10000 + SIZEOF_HEADERS} : .text ${RELOCATING+ 0x10000 + SIZEOF_HEADERS} :
{ {
CREATE_OBJECT_SYMBOLS CREATE_OBJECT_SYMBOLS
${RELOCATING+ __.text.start = .} ${RELOCATING+ __.text.start = .};
${RELOCATING+ __.init.start = .} ${RELOCATING+ __.init.start = .};
${RELOCATING+ LONG(0xf400c001)} ${RELOCATING+ LONG(0xf400c001)}
${RELOCATING+ __.init.end = .} ${RELOCATING+ __.init.end = .};
*(.text) *(.text)
${RELOCATING+ __.tdesc_start = .} ${RELOCATING+ __.tdesc_start = .};
${RELOCATING+ *(.tdesc)} ${RELOCATING+ *(.tdesc)}
${RELOCATING+ __.text_end = .} ${RELOCATING+ __.text_end = .} ;
${RELOCATING+ __.initp.start = .} ${RELOCATING+ __.initp.start = .};
${RELOCATING+ __.initp.end =.} ${RELOCATING+ __.initp.end =.};
${RELOCATING+_etext =.} ${RELOCATING+_etext =.};
} }
.data ${RELOCATING+ SIZEOF(.text) + ADDR(.text) + 0x400000} : .data ${RELOCATING+ SIZEOF(.text) + ADDR(.text) + 0x400000} :
{ {
*(.data) *(.data)
${CONSTRUCTING+CONSTRUCTORS} ${CONSTRUCTING+CONSTRUCTORS}
*(.comment) *(.comment)
${RELOCATING+_edata = .} ${RELOCATING+_edata = .};
} }
.bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} : .bss ${RELOCATING+ SIZEOF(.data) + ADDR(.data)} :
{ {
*(.bss) *(.bss)
*(COMMON) *(COMMON)
${RELOCATING+ _end = .} ${RELOCATING+ _end = .};
${RELOCATING+ __end = .} ${RELOCATING+ __end = .};
} }
} }
EOF EOF