aboutsummaryrefslogtreecommitdiff
path: root/ld/ldlang.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-02-15 02:11:05 +0000
committerAlan Modra <amodra@gmail.com>2002-02-15 02:11:05 +0000
commit2c382fb6f5499e01ce83c221f4b35f39e5b414f0 (patch)
treec5cf3c67e969823eb990910eeb4f777db60fdb22 /ld/ldlang.c
parentfd96f80fc8159f92a6d80a36ddbcfd274c4ef96a (diff)
downloadgdb-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.zip
gdb-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.tar.gz
gdb-2c382fb6f5499e01ce83c221f4b35f39e5b414f0.tar.bz2
Support arbitrary length fill patterns.
* ldexp.h (etree_value_type): Add "str" field. (union etree_union): Add "str" to "value" struct. (exp_bigintop): Declare. (exp_get_fill): Declare. * ldexp.c: Include "safe-ctype.h". (exp_intop): Set value.str to NULL. (exp_bigintop): New function. (new_rel): Pass in "str", and set new.str from it. (new_rel_from_section): Set new.str to NULL. (fold_name): Adjust calls to new_rel. (exp_fold_tree): Likewise. (exp_get_fill): New function. * ldgram.y (struct big_int bigint, fill_type *fill): New. (INT): Returns a "bigint". Adjust all code handling INTs. (fill_opt): Returns a "fill". (fill_exp): Split out of fill_opt, use for FILL. * ldlang.h (struct _fill_type): New. (fill_type): Move typedef to ldexp.h. (lang_output_section_statement_type): "fill" is now a pointer. (lang_fill_statement_type): Likewise. (lang_padding_statement_type): Likewise. (lang_add_fill): Now takes a "fill_type *" param. (lang_leave_output_section_statement): Likewise. (lang_do_assignments): Likewise. (lang_size_sections): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. * ldlang.c: Include ldgram.h after ldexp.h. (lang_output_section_statement_lookup): Adjust for fill_type change. (print_fill_statement): Likewise. (print_padding_statement): Likewise. (insert_pad): Now takes a "fill_type *" arg. (size_input_section): Likewise. (lang_size_sections_1): Likewise. (lang_size_sections): Likewise. (lang_do_assignments): Likewise. (lang_add_fill): Likewise. (lang_leave_output_section_statement): Likewise. (lang_leave_overlay_section): Likewise. (lang_leave_overlay): Likewise. Adjust all callers of the above function. * ldlex.l: Include ldgram.h after ldexp.h. Allow hex numbers starting with "0X" as well as "0x". Return bigint.str for hex numbers starting with "0x" or "0X", zero bigint.str otherwise. Always use base 16 for numbers starting with "$". * ldmain.c: Include ldgram.h after ldexp.h. * ldwrite.c (build_link_order): Use bfd_data_link_order in place of bfd_fill_link_order. * pe-dll.c: Adjust lang_do_assignments calls. * emultempl/elf32.em: Likewise. * emultempl/hppaelf.em: Likewise. * emultempl/ppc64elf.em: Likewise. * emultempl/beos.em: Include ldgram.h after ldexp.h, adjust lang_add_assignment call. * emultempl/pe.em: Likewise.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r--ld/ldlang.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 034d122..413ccf8 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -29,9 +29,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "ld.h"
#include "ldmain.h"
-#include "ldgram.h"
#include "ldexp.h"
#include "ldlang.h"
+#include "ldgram.h"
#include "ldlex.h"
#include "ldmisc.h"
#include "ldctor.h"
@@ -119,11 +119,11 @@ static void print_statement_list
PARAMS ((lang_statement_union_type *, lang_output_section_statement_type *));
static void print_statements PARAMS ((void));
static void insert_pad
- PARAMS ((lang_statement_union_type **, fill_type,
+ PARAMS ((lang_statement_union_type **, fill_type *,
unsigned int, asection *, bfd_vma));
static bfd_vma size_input_section
PARAMS ((lang_statement_union_type **, lang_output_section_statement_type *,
- fill_type, bfd_vma));
+ fill_type *, bfd_vma));
static void lang_finish PARAMS ((void));
static void ignore_bfd_errors PARAMS ((const char *, ...));
static void lang_check PARAMS ((void));
@@ -152,7 +152,7 @@ static void os_region_check
struct memory_region_struct *, etree_type *, bfd_vma));
static bfd_vma lang_size_sections_1
PARAMS ((lang_statement_union_type *, lang_output_section_statement_type *,
- lang_statement_union_type **, fill_type, bfd_vma, boolean *));
+ lang_statement_union_type **, fill_type *, bfd_vma, boolean *));
typedef void (*callback_t) PARAMS ((lang_wild_statement_type *,
struct wildcard_list *,
@@ -721,7 +721,7 @@ lang_output_section_statement_lookup (name)
new_stat (lang_output_section_statement, stat_ptr);
lookup->region = (lang_memory_region_type *) NULL;
lookup->lma_region = (lang_memory_region_type *) NULL;
- lookup->fill = 0;
+ lookup->fill = (fill_type *) 0;
lookup->block_value = 1;
lookup->name = name;
@@ -2313,7 +2313,12 @@ static void
print_fill_statement (fill)
lang_fill_statement_type *fill;
{
- fprintf (config.map_file, " FILL mask 0x%x\n", fill->fill);
+ size_t size;
+ unsigned char *p;
+ fputs (" FILL mask 0x", config.map_file);
+ for (p = fill->fill->data, size = fill->fill->size; size != 0; p++, size--)
+ fprintf (config.map_file, "%02x", *p);
+ fputs ("\n", config.map_file);
}
static void
@@ -2442,10 +2447,15 @@ print_padding_statement (s)
addr = s->output_offset;
if (s->output_section != NULL)
addr += s->output_section->vma;
- minfo ("0x%V %W", addr, s->size);
+ minfo ("0x%V %W ", addr, s->size);
- if (s->fill != 0)
- minfo (" %u", s->fill);
+ if (s->fill->size != 0)
+ {
+ size_t size;
+ unsigned char *p;
+ for (p = s->fill->data, size = s->fill->size; size != 0; p++, size--)
+ fprintf (config.map_file, "%02x", *p);
+ }
print_nl ();
@@ -2636,11 +2646,12 @@ dprint_statement (s, n)
static void
insert_pad (ptr, fill, alignment_needed, output_section, dot)
lang_statement_union_type **ptr;
- fill_type fill;
+ fill_type *fill;
unsigned int alignment_needed;
asection *output_section;
bfd_vma dot;
{
+ static fill_type zero_fill = { 1, { 0 } };
lang_statement_union_type *pad;
pad = ((lang_statement_union_type *)
@@ -2661,6 +2672,8 @@ insert_pad (ptr, fill, alignment_needed, output_section, dot)
*ptr = pad;
pad->header.type = lang_padding_statement_enum;
pad->padding_statement.output_section = output_section;
+ if (fill == (fill_type *) 0)
+ fill = &zero_fill;
pad->padding_statement.fill = fill;
}
pad->padding_statement.output_offset = dot - output_section->vma;
@@ -2674,7 +2687,7 @@ static bfd_vma
size_input_section (this_ptr, output_section_statement, fill, dot)
lang_statement_union_type **this_ptr;
lang_output_section_statement_type *output_section_statement;
- fill_type fill;
+ fill_type *fill;
bfd_vma dot;
{
lang_input_section_type *is = &((*this_ptr)->input_section);
@@ -2831,7 +2844,7 @@ lang_size_sections_1 (s, output_section_statement, prev, fill, dot, relax)
lang_statement_union_type *s;
lang_output_section_statement_type *output_section_statement;
lang_statement_union_type **prev;
- fill_type fill;
+ fill_type *fill;
bfd_vma dot;
boolean *relax;
{
@@ -3207,7 +3220,7 @@ lang_size_sections (s, output_section_statement, prev, fill, dot, relax)
lang_statement_union_type *s;
lang_output_section_statement_type *output_section_statement;
lang_statement_union_type **prev;
- fill_type fill;
+ fill_type *fill;
bfd_vma dot;
boolean *relax;
{
@@ -3242,7 +3255,7 @@ bfd_vma
lang_do_assignments (s, output_section_statement, fill, dot)
lang_statement_union_type *s;
lang_output_section_statement_type *output_section_statement;
- fill_type fill;
+ fill_type *fill;
bfd_vma dot;
{
unsigned opb = bfd_arch_mach_octets_per_byte (ldfile_output_architecture,
@@ -4211,7 +4224,7 @@ lang_process ()
section sizes. */
lang_do_assignments (statement_list.head,
abs_output_section,
- (fill_type) 0, (bfd_vma) 0);
+ (fill_type *) 0, (bfd_vma) 0);
/* Perform another relax pass - this time we know where the
globals are, so can make better guess. */
@@ -4235,7 +4248,7 @@ lang_process ()
lang_do_assignments (statement_list.head,
abs_output_section,
- (fill_type) 0, (bfd_vma) 0);
+ (fill_type *) 0, (bfd_vma) 0);
/* Make sure that the section addresses make sense. */
if (! link_info.relocateable
@@ -4351,13 +4364,13 @@ lang_add_map (name)
}
void
-lang_add_fill (exp)
- int exp;
+lang_add_fill (fill)
+ fill_type *fill;
{
lang_fill_statement_type *new = new_stat (lang_fill_statement,
stat_ptr);
- new->fill = exp;
+ new->fill = fill;
}
void
@@ -4444,7 +4457,7 @@ lang_float (maybe)
void
lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec)
- bfd_vma fill;
+ fill_type *fill;
const char *memspec;
struct lang_output_section_phdr_list *phdrs;
const char *lma_memspec;
@@ -4822,7 +4835,7 @@ lang_enter_overlay_section (name)
void
lang_leave_overlay_section (fill, phdrs)
- bfd_vma fill;
+ fill_type *fill;
struct lang_output_section_phdr_list *phdrs;
{
const char *name;
@@ -4864,7 +4877,7 @@ lang_leave_overlay_section (fill, phdrs)
void
lang_leave_overlay (fill, memspec, phdrs, lma_memspec)
- bfd_vma fill;
+ fill_type *fill;
const char *memspec;
struct lang_output_section_phdr_list *phdrs;
const char *lma_memspec;
@@ -4894,7 +4907,7 @@ lang_leave_overlay (fill, memspec, phdrs, lma_memspec)
{
struct overlay_list *next;
- if (fill != 0 && l->os->fill == 0)
+ if (fill != (fill_type *) 0 && l->os->fill == (fill_type *) 0)
l->os->fill = fill;
/* Assign a region to the sections, if one has been specified.