* 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:
parent
f6492282df
commit
ae475b39b2
5 changed files with 339 additions and 264 deletions
11
ld/ChangeLog
11
ld/ChangeLog
|
@ -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)
|
||||
|
||||
* ldint.texinfo: New internals manual (beginnings thereof).
|
||||
|
|
|
@ -53,10 +53,10 @@ static char *h8300hms_script =
|
|||
#include "h8300hms.x"
|
||||
;
|
||||
static char *h8300hms_script_option_Ur =
|
||||
#include "h8300hms.x"
|
||||
#include "h8300hms.xu"
|
||||
;
|
||||
static char *h8300hms_script_option_r =
|
||||
#include "h8300hms.x"
|
||||
#include "h8300hms.xr"
|
||||
;
|
||||
|
||||
static char *h8300hms_get_script()
|
||||
|
|
|
@ -16,23 +16,23 @@ SECTIONS
|
|||
{
|
||||
*(.text)
|
||||
*(.strings)
|
||||
_etext = .;
|
||||
${RELOCATING+ _etext = . ; }
|
||||
} ${RELOCATING+ > ram}
|
||||
.data :
|
||||
{
|
||||
*(.data)
|
||||
_edata = .;
|
||||
${RELOCATING+ _edata = . ; }
|
||||
} ${RELOCATING+ > ram}
|
||||
.bss :
|
||||
{
|
||||
${RELOCATING+ _bss_start = .};
|
||||
${RELOCATING+ _bss_start = . ;}
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
${RELOCATING+ _end = .};
|
||||
${RELOCATING+ _end = . ; }
|
||||
} ${RELOCATING+ >ram}
|
||||
.stack :
|
||||
{
|
||||
_stack = .;
|
||||
${RELOCATING+ _stack = . ; }
|
||||
*(.stack)
|
||||
} ${RELOCATING+ > topram}
|
||||
}
|
||||
|
|
16
ld/ldgram.y
16
ld/ldgram.y
|
@ -299,7 +299,7 @@ command_line_option:
|
|||
{ lang_add_input_file($1,lang_input_file_is_file_enum,
|
||||
(char *)NULL); }
|
||||
| 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
|
||||
{ ldfile_open_command_file($1); } script_file
|
||||
|
@ -327,7 +327,7 @@ END { ldlex_command();}
|
|||
lang_add_assignment(exp_assop($4,$3,$5));
|
||||
}
|
||||
| '-' NAME
|
||||
{ info("%P%F Unrecognised option -%s\n", $2); }
|
||||
{ info("%P%F Unrecognized option -%s\n", $2); }
|
||||
|
||||
| '{' script_file '}'
|
||||
;
|
||||
|
@ -747,6 +747,8 @@ exp :
|
|||
{ $$ = exp_nameop(SIZEOF,$3); }
|
||||
| ADDR '(' NAME ')'
|
||||
{ $$ = exp_nameop(ADDR,$3); }
|
||||
| ABSOLUTE '(' exp ')'
|
||||
{ $$ = exp_unop(ABSOLUTE, $3); }
|
||||
| ALIGN_K '(' exp ')'
|
||||
{ $$ = exp_unop(ALIGN_K,$3); }
|
||||
| NAME
|
||||
|
@ -772,11 +774,11 @@ opt_comma
|
|||
;
|
||||
|
||||
opt_type:
|
||||
'(' NOLOAD ')' { $$ = SEC_NO_FLAGS; }
|
||||
| '(' DSECT ')' { $$ = 0; }
|
||||
| '(' COPY ')' { $$ = 0; }
|
||||
| '(' INFO ')' { $$ = 0; }
|
||||
| '(' OVERLAY ')' { $$ = 0; }
|
||||
NOLOAD { $$ = SEC_NEVER_LOAD; }
|
||||
| DSECT { $$ = 0; }
|
||||
| COPY { $$ = 0; }
|
||||
| INFO { $$ = 0; }
|
||||
| OVERLAY { $$ = 0; }
|
||||
| { $$ = SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS; }
|
||||
;
|
||||
|
||||
|
|
120
ld/ldlang.c
120
ld/ldlang.c
|
@ -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
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||
|
||||
/* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#include "bfd.h"
|
||||
#include "sysdep.h"
|
||||
|
||||
|
@ -459,6 +455,7 @@ DEFUN (lang_output_section_statement_lookup, (name),
|
|||
lookup->next = (lang_statement_union_type *) NULL;
|
||||
lookup->bfd_section = (asection *) NULL;
|
||||
lookup->processed = false;
|
||||
lookup->loadable = 1;
|
||||
lookup->addr_tree = (etree_type *) NULL;
|
||||
lang_list_init (&lookup->children);
|
||||
|
||||
|
@ -497,7 +494,9 @@ DEFUN_VOID (lang_map)
|
|||
#ifdef HOST_64_BIT
|
||||
fprintf (config.map_file, "name\t\torigin\t\tlength\t\tattributes\n");
|
||||
#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
|
||||
for (m = lang_memory_region_list;
|
||||
m != (lang_memory_region_type *) NULL;
|
||||
|
@ -508,6 +507,12 @@ DEFUN_VOID (lang_map)
|
|||
print_space ();
|
||||
print_address (m->length);
|
||||
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);
|
||||
fprintf (config.map_file, "\n");
|
||||
}
|
||||
|
@ -585,6 +590,11 @@ DEFUN (wild_doit, (ptr, section, output, file),
|
|||
new->ifile = file;
|
||||
section->output_section = output->bfd_section;
|
||||
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)
|
||||
{
|
||||
output->bfd_section->alignment_power = section->alignment_power;
|
||||
|
@ -1009,7 +1019,9 @@ DEFUN (print_output_section_statement, (output_section_statement),
|
|||
print_space ();
|
||||
print_address (section->vma);
|
||||
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_alignment (section->alignment_power);
|
||||
print_space ();
|
||||
|
@ -1112,7 +1124,9 @@ DEFUN (print_input_section, (in),
|
|||
{
|
||||
print_address (i->output_section->vma + i->output_offset);
|
||||
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, " ");
|
||||
print_alignment (i->alignment_power);
|
||||
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 */
|
||||
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_output_section_statement_type * output_section_statement AND
|
||||
unsigned short fill AND
|
||||
bfd_vma dot)
|
||||
bfd_vma dot AND
|
||||
boolean relax)
|
||||
{
|
||||
lang_input_section_type *is = &((*this_ptr)->input_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;
|
||||
|
||||
/* 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 =
|
||||
dot - output_section_statement->bfd_section->vma;
|
||||
/* Mark how big the output section must be to contain this now
|
||||
*/
|
||||
if (relax)
|
||||
{
|
||||
dot += i->_cooked_size;
|
||||
}
|
||||
else
|
||||
{
|
||||
dot += i->_raw_size;
|
||||
}
|
||||
output_section_statement->bfd_section->_raw_size = dot - output_section_statement->bfd_section->vma;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1587,14 +1610,20 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill,
|
|||
{
|
||||
relaxing = true;
|
||||
|
||||
had_relax = had_relax || relax_section (prev);
|
||||
if( relax_section (prev))
|
||||
had_relax = true;
|
||||
relaxing = false;
|
||||
|
||||
}
|
||||
else {
|
||||
(*prev)->input_section.section->_cooked_size =
|
||||
(*prev)->input_section.section->_raw_size ;
|
||||
|
||||
}
|
||||
dot = size_input_section (prev,
|
||||
output_section_statement,
|
||||
output_section_statement->fill, dot);
|
||||
output_section_statement->fill,
|
||||
dot, relax);
|
||||
break;
|
||||
case lang_input_statement_enum:
|
||||
break;
|
||||
|
@ -2202,6 +2231,10 @@ DEFUN (lang_enter_output_section_statement,
|
|||
address_exp;
|
||||
}
|
||||
os->flags = flags;
|
||||
if (flags & SEC_NEVER_LOAD)
|
||||
os->loadable = 0;
|
||||
else
|
||||
os->loadable = 1;
|
||||
os->block_value = block_value;
|
||||
stat_ptr = &os->children;
|
||||
|
||||
|
@ -2228,11 +2261,13 @@ DEFUN_VOID (reset_memory_regions)
|
|||
p != (lang_memory_region_type *) NULL;
|
||||
p = p->next)
|
||||
{
|
||||
p->old_length = p->current - p->origin;
|
||||
p->current = p->origin;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
asymbol *
|
||||
DEFUN (create_symbol, (name, flags, section),
|
||||
CONST char *name AND
|
||||
|
@ -2301,20 +2336,7 @@ DEFUN_VOID (lang_process)
|
|||
ldemul_before_allocation ();
|
||||
|
||||
|
||||
/* Size up the sections */
|
||||
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 ();
|
||||
|
||||
#if 0
|
||||
had_relax = true;
|
||||
while (had_relax)
|
||||
{
|
||||
|
@ -2330,9 +2352,49 @@ DEFUN_VOID (lang_process)
|
|||
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);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue