aboutsummaryrefslogtreecommitdiff
path: root/ld/lexsup.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-10-26 18:41:52 +0000
committerMark Mitchell <mark@codesourcery.com>2004-10-26 18:41:52 +0000
commitba916c8af2642aebace1778a707e90a6a4f9095f (patch)
treecb164ef2f690eeb1dda279b88015e5e9aa59073d /ld/lexsup.c
parent1ec5cd372135a64c39eeaa32103cad2913e1754a (diff)
downloadgdb-ba916c8af2642aebace1778a707e90a6a4f9095f.zip
gdb-ba916c8af2642aebace1778a707e90a6a4f9095f.tar.gz
gdb-ba916c8af2642aebace1778a707e90a6a4f9095f.tar.bz2
* Makefile.in (earmsymbian.c): Depend on armbpabi.sc, not elf.sc.
* ldexp.h (segment_type): New type. (segments): New variable. * ldexp.c (segments): New variable. (exp_print_token): Handle SEGMENT_START. (fold_binary): Likewise. * ldgram.y (SEGMENT_START): Declare it as a token. (exp): Handle SEGMENT_START. * ldlang.h (lang_address_statement_type): Add segment field. (lang_section_start): Change prototype. * ldlang.c (map_input_to_output_sections): Do not process section assignments if a corresponding SEGMENT_START has already been seen. (lang_section_start): Add segment parameter. * ldlex.l (SEGMENT_START): Add it. * lexsup.c (seg_segment_start): New function. (parse_args): Use it for -Tbss, -Tdata, and -Ttext. * ld.texinfo (SEGMENT_START): Document it. * emulparams/armsymbian.sh (EMBEDDED): Set it. * scripttempl/armbpabi.sc: Use SEGMENT_START to control segment base addresses. Do not map relocations. * NEWS: Mention SEGMENT_START.
Diffstat (limited to 'ld/lexsup.c')
-rw-r--r--ld/lexsup.c45
1 files changed, 41 insertions, 4 deletions
diff --git a/ld/lexsup.c b/ld/lexsup.c
index be7c0a9..28f28ff 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -55,6 +55,7 @@
static void set_default_dirlist (char *);
static void set_section_start (char *, char *);
+static void set_segment_start (const char *, char *);
static void help (void);
/* Non-zero if we are processing a --defsym from the command line. */
@@ -1138,13 +1139,13 @@ parse_args (unsigned argc, char **argv)
ldemul_list_emulation_options (stdout);
exit (0);
case OPTION_TBSS:
- set_section_start (".bss", optarg);
+ set_segment_start (".bss", optarg);
break;
case OPTION_TDATA:
- set_section_start (".data", optarg);
+ set_segment_start (".data", optarg);
break;
case OPTION_TTEXT:
- set_section_start (".text", optarg);
+ set_segment_start (".text", optarg);
break;
case OPTION_TRADITIONAL_FORMAT:
link_info.traditional_format = TRUE;
@@ -1380,8 +1381,44 @@ set_section_start (char *sect, char *valstr)
bfd_vma val = bfd_scan_vma (valstr, &end, 16);
if (*end)
einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
- lang_section_start (sect, exp_intop (val));
+ lang_section_start (sect, exp_intop (val), NULL);
}
+
+static void
+set_segment_start (const char *section, char *valstr)
+{
+ const char *name;
+ const char *end;
+ segment_type *seg;
+
+ bfd_vma val = bfd_scan_vma (valstr, &end, 16);
+ if (*end)
+ einfo (_("%P%F: invalid hex number `%s'\n"), valstr);
+ /* If we already have an entry for this segment, update the existing
+ value. */
+ name = section + 1;
+ for (seg = segments; seg; seg = seg->next)
+ if (strcmp (seg->name, name) == 0)
+ {
+ seg->value = val;
+ return;
+ }
+ /* There was no existing value so we must create a new segment
+ entry. */
+ seg = stat_alloc (sizeof (*seg));
+ seg->name = name;
+ seg->value = val;
+ seg->used = FALSE;
+ /* Add it to the linked list of segments. */
+ seg->next = segments;
+ segments = seg;
+ /* Historically, -Ttext and friends set the base address of a
+ particular section. For backwards compatibility, we still do
+ that. If a SEGMENT_START directive is seen, the section address
+ assignment will be disabled. */
+ lang_section_start (section, exp_intop (val), seg);
+}
+
/* Print help messages for the options. */