* ldlang.h: add new field "loadable" to output_section_statement.

* ldlang.c (lang_output_section_statement_lookup): initilize new
	field. (wild_doit): if new field is not set, then stop output
	section from being loadable.
	(lang_enter_output_section_statement): set the field from the
	NOLOAD keyword
	* ldgram.y: new synax for NOLOAD. Removes a shift/reduce too.
	* h8300hms.sc-sh, h8300hms.em: get -r right.
This commit is contained in:
Steve Chamberlain
1992-08-07 19:34:59 +00:00
parent f6492282df
commit ae475b39b2
5 changed files with 339 additions and 264 deletions

View File

@ -1,3 +1,14 @@
Fri Aug 7 12:31:10 1992 Steve Chamberlain (sac@thepub.cygnus.com)
* ldlang.h: add new field "loadable" to output_section_statement.
* ldlang.c (lang_output_section_statement_lookup): initilize new
field. (wild_doit): if new field is not set, then stop output
section from being loadable.
(lang_enter_output_section_statement): set the field from the
NOLOAD keyword
* ldgram.y: new synax for NOLOAD. Removes a shift/reduce too.
* h8300hms.sc-sh, h8300hms.em: get -r right.
Thu Aug 6 18:35:21 1992 Per Bothner (bothner@rtl.cygnus.com) Thu Aug 6 18:35:21 1992 Per Bothner (bothner@rtl.cygnus.com)
* ldint.texinfo: New internals manual (beginnings thereof). * ldint.texinfo: New internals manual (beginnings thereof).

View File

@ -53,10 +53,10 @@ static char *h8300hms_script =
#include "h8300hms.x" #include "h8300hms.x"
; ;
static char *h8300hms_script_option_Ur = static char *h8300hms_script_option_Ur =
#include "h8300hms.x" #include "h8300hms.xu"
; ;
static char *h8300hms_script_option_r = static char *h8300hms_script_option_r =
#include "h8300hms.x" #include "h8300hms.xr"
; ;
static char *h8300hms_get_script() static char *h8300hms_get_script()

View File

@ -16,23 +16,23 @@ SECTIONS
{ {
*(.text) *(.text)
*(.strings) *(.strings)
_etext = .; ${RELOCATING+ _etext = . ; }
} ${RELOCATING+ > ram} } ${RELOCATING+ > ram}
.data : .data :
{ {
*(.data) *(.data)
_edata = .; ${RELOCATING+ _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 :
{ {
_stack = .; ${RELOCATING+ _stack = . ; }
*(.stack) *(.stack)
} ${RELOCATING+ > topram} } ${RELOCATING+ > topram}
} }

View File

@ -299,7 +299,7 @@ command_line_option:
{ lang_add_input_file($1,lang_input_file_is_file_enum, { lang_add_input_file($1,lang_input_file_is_file_enum,
(char *)NULL); } (char *)NULL); }
| OPTION_c filename | OPTION_c filename
{ ldfile_open_command_file($2); } mri_script_file END { ldlex_command()}; { ldfile_open_command_file($2); } mri_script_file END { ldlex_command();}
| OPTION_Tfile | OPTION_Tfile
{ ldfile_open_command_file($1); } script_file { ldfile_open_command_file($1); } script_file
@ -327,7 +327,7 @@ END { ldlex_command();}
lang_add_assignment(exp_assop($4,$3,$5)); lang_add_assignment(exp_assop($4,$3,$5));
} }
| '-' NAME | '-' NAME
{ info("%P%F Unrecognised option -%s\n", $2); } { info("%P%F Unrecognized option -%s\n", $2); }
| '{' script_file '}' | '{' script_file '}'
; ;
@ -747,6 +747,8 @@ exp :
{ $$ = exp_nameop(SIZEOF,$3); } { $$ = exp_nameop(SIZEOF,$3); }
| ADDR '(' NAME ')' | ADDR '(' NAME ')'
{ $$ = exp_nameop(ADDR,$3); } { $$ = exp_nameop(ADDR,$3); }
| ABSOLUTE '(' exp ')'
{ $$ = exp_unop(ABSOLUTE, $3); }
| ALIGN_K '(' exp ')' | ALIGN_K '(' exp ')'
{ $$ = exp_unop(ALIGN_K,$3); } { $$ = exp_unop(ALIGN_K,$3); }
| NAME | NAME
@ -772,11 +774,11 @@ opt_comma
; ;
opt_type: opt_type:
'(' NOLOAD ')' { $$ = SEC_NO_FLAGS; } NOLOAD { $$ = SEC_NEVER_LOAD; }
| '(' DSECT ')' { $$ = 0; } | DSECT { $$ = 0; }
| '(' COPY ')' { $$ = 0; } | COPY { $$ = 0; }
| '(' INFO ')' { $$ = 0; } | INFO { $$ = 0; }
| '(' OVERLAY ')' { $$ = 0; } | OVERLAY { $$ = 0; }
| { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; } | { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
; ;

View File

@ -16,10 +16,6 @@ You should have received a copy of the GNU General Public License
along with GLD; see the file COPYING. If not, write to along with GLD; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $Id$
*
*/
#include "bfd.h" #include "bfd.h"
#include "sysdep.h" #include "sysdep.h"
@ -459,6 +455,7 @@ DEFUN (lang_output_section_statement_lookup, (name),
lookup->next = (lang_statement_union_type *) NULL; lookup->next = (lang_statement_union_type *) NULL;
lookup->bfd_section = (asection *) NULL; lookup->bfd_section = (asection *) NULL;
lookup->processed = false; lookup->processed = false;
lookup->loadable = 1;
lookup->addr_tree = (etree_type *) NULL; lookup->addr_tree = (etree_type *) NULL;
lang_list_init (&lookup->children); lang_list_init (&lookup->children);
@ -497,7 +494,9 @@ DEFUN_VOID (lang_map)
#ifdef HOST_64_BIT #ifdef HOST_64_BIT
fprintf (config.map_file, "name\t\torigin\t\tlength\t\tattributes\n"); fprintf (config.map_file, "name\t\torigin\t\tlength\t\tattributes\n");
#else #else
fprintf (config.map_file, "name\t\torigin length\t\tattributes\n"); fprintf (config.map_file,
"name\t\torigin length r_size c_size is attributes\n");
#endif #endif
for (m = lang_memory_region_list; for (m = lang_memory_region_list;
m != (lang_memory_region_type *) NULL; m != (lang_memory_region_type *) NULL;
@ -508,6 +507,12 @@ DEFUN_VOID (lang_map)
print_space (); print_space ();
print_address (m->length); print_address (m->length);
print_space (); print_space ();
print_address (m->old_length);
print_space();
print_address (m->current - m->origin);
print_space();
if (m->old_length)
fprintf(config.map_file," %2d%% ", ( m->current - m->origin) * 100 / m->old_length);
print_flags (&m->flags); print_flags (&m->flags);
fprintf (config.map_file, "\n"); fprintf (config.map_file, "\n");
} }
@ -585,6 +590,11 @@ DEFUN (wild_doit, (ptr, section, output, file),
new->ifile = file; new->ifile = file;
section->output_section = output->bfd_section; section->output_section = output->bfd_section;
section->output_section->flags |= section->flags; section->output_section->flags |= section->flags;
if (!output->loadable)
{
/* Turn of load flag */
output->bfd_section->flags &= ~SEC_LOAD;
}
if (section->alignment_power > output->bfd_section->alignment_power) if (section->alignment_power > output->bfd_section->alignment_power)
{ {
output->bfd_section->alignment_power = section->alignment_power; output->bfd_section->alignment_power = section->alignment_power;
@ -1009,7 +1019,9 @@ DEFUN (print_output_section_statement, (output_section_statement),
print_space (); print_space ();
print_address (section->vma); print_address (section->vma);
print_space (); print_space ();
print_size (bfd_get_section_size_before_reloc (section)); print_size (section->_raw_size);
print_space();
print_size(section->_cooked_size);
print_space (); print_space ();
print_alignment (section->alignment_power); print_alignment (section->alignment_power);
print_space (); print_space ();
@ -1112,7 +1124,9 @@ DEFUN (print_input_section, (in),
{ {
print_address (i->output_section->vma + i->output_offset); print_address (i->output_section->vma + i->output_offset);
fprintf (config.map_file, " "); fprintf (config.map_file, " ");
print_size (size); print_size (i->_raw_size);
fprintf (config.map_file, " ");
print_size(i->_cooked_size);
fprintf (config.map_file, " "); fprintf (config.map_file, " ");
print_alignment (i->alignment_power); print_alignment (i->alignment_power);
fprintf (config.map_file, " "); fprintf (config.map_file, " ");
@ -1382,11 +1396,13 @@ DEFUN (insert_pad, (this_ptr, fill, power, output_section_statement, dot),
/* Work out how much this section will move the dot point */ /* Work out how much this section will move the dot point */
static bfd_vma static bfd_vma
DEFUN (size_input_section, (this_ptr, output_section_statement, fill, dot), DEFUN (size_input_section, (this_ptr, output_section_statement, fill,
dot, relax),
lang_statement_union_type ** this_ptr AND lang_statement_union_type ** this_ptr AND
lang_output_section_statement_type * output_section_statement AND lang_output_section_statement_type * output_section_statement AND
unsigned short fill AND unsigned short fill AND
bfd_vma dot) bfd_vma dot AND
boolean relax)
{ {
lang_input_section_type *is = &((*this_ptr)->input_section); lang_input_section_type *is = &((*this_ptr)->input_section);
asection *i = is->section; asection *i = is->section;
@ -1410,10 +1426,17 @@ DEFUN (size_input_section, (this_ptr, output_section_statement, fill, dot),
i->output_offset = dot - output_section_statement->bfd_section->vma; i->output_offset = dot - output_section_statement->bfd_section->vma;
/* Mark how big the output section must be to contain this now */ /* Mark how big the output section must be to contain this now
dot += bfd_get_section_size_before_reloc (i); */
output_section_statement->bfd_section->_raw_size = if (relax)
dot - output_section_statement->bfd_section->vma; {
dot += i->_cooked_size;
}
else
{
dot += i->_raw_size;
}
output_section_statement->bfd_section->_raw_size = dot - output_section_statement->bfd_section->vma;
} }
else else
{ {
@ -1587,14 +1610,20 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill,
{ {
relaxing = true; relaxing = true;
had_relax = had_relax || relax_section (prev); if( relax_section (prev))
had_relax = true;
relaxing = false; relaxing = false;
} }
else {
(*prev)->input_section.section->_cooked_size =
(*prev)->input_section.section->_raw_size ;
}
dot = size_input_section (prev, dot = size_input_section (prev,
output_section_statement, output_section_statement,
output_section_statement->fill, dot); output_section_statement->fill,
dot, relax);
break; break;
case lang_input_statement_enum: case lang_input_statement_enum:
break; break;
@ -2202,6 +2231,10 @@ DEFUN (lang_enter_output_section_statement,
address_exp; address_exp;
} }
os->flags = flags; os->flags = flags;
if (flags & SEC_NEVER_LOAD)
os->loadable = 0;
else
os->loadable = 1;
os->block_value = block_value; os->block_value = block_value;
stat_ptr = &os->children; stat_ptr = &os->children;
@ -2228,11 +2261,13 @@ DEFUN_VOID (reset_memory_regions)
p != (lang_memory_region_type *) NULL; p != (lang_memory_region_type *) NULL;
p = p->next) p = p->next)
{ {
p->old_length = p->current - p->origin;
p->current = p->origin; p->current = p->origin;
} }
} }
asymbol * asymbol *
DEFUN (create_symbol, (name, flags, section), DEFUN (create_symbol, (name, flags, section),
CONST char *name AND CONST char *name AND
@ -2301,20 +2336,7 @@ DEFUN_VOID (lang_process)
ldemul_before_allocation (); ldemul_before_allocation ();
/* Size up the sections */ #if 0
lang_size_sections (statement_list.head,
abs_output_section,
&(statement_list.head), 0, (bfd_vma) 0, false);
/* Now run around and relax if we can */
if (command_line.relax)
{
reset_memory_regions ();
/* Move the global symbols around */
lang_relocate_globals ();
had_relax = true; had_relax = true;
while (had_relax) while (had_relax)
{ {
@ -2330,9 +2352,49 @@ DEFUN_VOID (lang_process)
break; break;
} }
#endif
/* Now run around and relax if we can */
if (command_line.relax)
{
/* First time round is a trial run to get the 'worst case' addresses of the
objects if there was no relaxing */
lang_size_sections (statement_list.head,
(lang_output_section_statement_type *) NULL,
&(statement_list.head), 0, (bfd_vma) 0, false);
/* Move the global symbols around so the second pass of relaxing can
see them */
lang_relocate_globals ();
reset_memory_regions ();
/* Do all the assignments, now that we know the final restingplaces
of all the symbols */
lang_do_assignments (statement_list.head,
abs_output_section,
0, (bfd_vma) 0);
/* Perform another relax pass - this time we know where the
globals are, so can make better guess */
lang_size_sections (statement_list.head,
(lang_output_section_statement_type *) NULL,
&(statement_list.head), 0, (bfd_vma) 0, true);
}
else
{
/* Size up the sections */
lang_size_sections (statement_list.head,
abs_output_section,
&(statement_list.head), 0, (bfd_vma) 0, false);
} }