static void obj_elf_line PARAMS ((void));
void obj_elf_desc PARAMS ((void));
void obj_elf_version PARAMS ((void));
-static void obj_elf_section PARAMS ((int));
static void obj_elf_size PARAMS ((void));
static void obj_elf_type PARAMS ((void));
static void obj_elf_ident PARAMS ((void));
-static void obj_elf_previous PARAMS ((void));
const pseudo_typeS obj_pseudo_table[] =
{
static segT previous_section;
static int previous_subsection;
-static void
+void
obj_elf_section (xxx)
int xxx;
{
input_line_pointer = p;
}
if (!strcmp (string, ".rodata"))
- default_flags = SEC_ALLOC | SEC_READONLY | SEC_RELOC;
+ default_flags = SEC_ALLOC | SEC_READONLY | SEC_RELOC;
+ else if (!strcmp (string, ".init")
+ || !strcmp (string, ".fini"))
+ default_flags = SEC_ALLOC | SEC_READONLY | SEC_RELOC | SEC_CODE;
SKIP_WHITESPACE ();
if (*input_line_pointer != ',')
flags = default_flags;
subseg_set (sec, 0);
}
-static void
+void
obj_elf_previous ()
{
if (previous_section == 0)
symbolS *sym;
int *punt;
{
+#if 0 /* ?? The return value is ignored. Only the value of *punt is
+ relevant. */
return obj_elf_write_symbol_p (sym);
+#endif
}
static void
int saved_type = 0;
int length;
int goof = 0;
+ int seg_is_new = 0;
long longint;
asection *saved_seg = now_seg;
asection *seg;
#if 1
/* This function doesn't work yet.
- Actually, this function is okay, but some finalizations are needed
- before writing the object file; that's not done yet, and the Solaris
- linker chokes without it.
+ Actually, this function is okay, but some finalizations are
+ needed before writing the object file; that's not done yet, and
+ the Solaris linker chokes without it.
In any case, this should effectively disable it for now. */
if (what == 's')
bfd_set_section_flags (stdoutput, seg,
SEC_READONLY | SEC_ALLOC | SEC_RELOC);
subseg_set (saved_seg, subseg);
+ seg_is_new = 1;
}
/*
}
}
- if (!goof)
+ if (goof)
{
- subseg_new ((char *) seg->name, subseg);
+ ignore_rest_of_line ();
+ return;
+ }
- /* Emit the stab symbol. */
- elf_stab_symbol (symbolP, what);
+ subseg_new ((char *) seg->name, subseg);
- if (what == 's' || what == 'n')
- {
- cons (4);
- input_line_pointer--;
- }
- else
- {
- char *p = frag_more (4);
- md_number_to_chars (p, 0, 0);
- }
- subseg_new ((char *) saved_seg->name, subseg);
+ if (seg_is_new)
+ /* allocate and discard -- filled in later */
+ (void) frag_more (12);
- if ((what == 's' || what == 'n')
- && symbolP->sy_value.X_op == O_constant)
- {
- /* symbol is not needed in the regular symbol table */
- symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
- }
+ /* Emit the stab symbol. */
+ elf_stab_symbol (symbolP, what);
+ if (what == 's' || what == 'n')
+ {
+ cons (4);
+ input_line_pointer--;
+ }
+ else
+ {
+ char *p = frag_more (4);
+ md_number_to_chars (p, 0, 0);
}
-#ifndef NO_LISTING
- if (listing && !goof)
+ subseg_new ((char *) saved_seg->name, subseg);
+
+ if ((what == 's' || what == 'n')
+ && symbolP->sy_value.X_op == O_constant)
+ {
+ /* symbol is not needed in the regular symbol table */
+ symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
+ }
+
+ if (what == 's' && S_GET_TYPE (symbolP) == N_SO)
+ {
+ fragS *fragp = seg_info (seg)->frchainP->frch_root;
+ while (fragp
+ && fragp->fr_address + fragp->fr_fix < 12)
+ fragp = fragp->fr_next;
+ assert (fragp != 0);
+ assert (fragp->fr_type == rs_fill);
+ assert (fragp->fr_address == 0 && fragp->fr_fix >= 12);
+ md_number_to_chars (fragp->fr_literal, (valueT) symbolP->sy_name_offset,
+ 4);
+ }
+
+ if (listing)
switch (S_GET_TYPE (symbolP))
{
case N_SLINE:
listing_source_file (string);
break;
}
-#endif
- if (goof)
- ignore_rest_of_line ();
- else
- demand_empty_rest_of_line ();
+ demand_empty_rest_of_line ();
}
static void
subseg_new ((char *) note_secp->name, 0);
len = strlen (name);
- i_note.namesz = ((len + 1) + 3) & ~3; /* round this to word boundary */
- i_note.descsz = 0; /* no description */
+ i_note.namesz = ((len + 1) + 3) & ~3; /* round this to word boundary */
+ i_note.descsz = 0; /* no description */
i_note.type = NT_VERSION;
p = frag_more (sizeof (e_note.namesz));
md_number_to_chars (p, (valueT) i_note.namesz, 4);
}
else
{
- as_bad ("Expected \"-ed string");
+ as_bad ("Expected quoted string");
}
demand_empty_rest_of_line ();
}
subseg_set (old_section, old_subsection);
}
+static void
+adjust_stab_sections (abfd, sec, xxx)
+ bfd *abfd;
+ asection *sec;
+ PTR xxx;
+{
+ char *name;
+ asection *strsec;
+ fragS *fragp;
+ int strsz, nsyms;
+
+ if (strncmp (".stab", sec->name, 5))
+ return;
+ if (!strcmp ("str", sec->name + strlen (sec->name) - 3))
+ return;
+
+ name = (char *) alloca (strlen (sec->name) + 4);
+ strcpy (name, sec->name);
+ strcat (name, "str");
+ strsec = bfd_get_section_by_name (abfd, name);
+ if (strsec)
+ strsz = bfd_section_size (abfd, strsec);
+ else
+ strsz = 0;
+ nsyms = bfd_section_size (abfd, sec) / 12 - 1;
+
+ fragp = seg_info (sec)->frchainP->frch_root;
+ while (fragp
+ && fragp->fr_address + fragp->fr_fix < 12)
+ fragp = fragp->fr_next;
+ assert (fragp != 0);
+ assert (fragp->fr_type == rs_fill);
+ assert (fragp->fr_address == 0 && fragp->fr_fix >= 12);
+
+ bfd_h_put_16 (abfd, nsyms, fragp->fr_literal + 6);
+ bfd_h_put_32 (abfd, strsz, fragp->fr_literal + 8);
+}
+
void
elf_frob_file ()
{
+ bfd_map_over_sections (stdoutput, adjust_stab_sections, (PTR) 0);
+
#ifdef elf_tc_symbol
- int i;
+ {
+ int i;
- for (i = 0; i < stdoutput->symcount; i++)
- elf_tc_symbol (stdoutput, (elf_symbol_type *) (stdoutput->outsymbols[i]), i + 1);
+ for (i = 0; i < stdoutput->symcount; i++)
+ elf_tc_symbol (stdoutput, (elf_symbol_type *) (stdoutput->outsymbols[i]),
+ i + 1);
+ }
#endif
+
#ifdef elf_tc_final_processing
elf_tc_final_processing_hook ();
#endif