* config/obj-coff-seh.c (seh_arm_write_pdata): Test for

seh_ctx_root being NULL.
This commit is contained in:
Nick Clifton 2009-08-26 08:26:53 +00:00
parent 0666b2c367
commit 604ab327fd
2 changed files with 184 additions and 167 deletions

View File

@ -1,3 +1,8 @@
2009-08-26 Nick Clifton <nickc@redhat.com>
* config/obj-coff-seh.c (seh_arm_write_pdata): Test for
seh_ctx_root being NULL.
2009-08-24 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.am (am__skiplex, am__skipyacc): New.

View File

@ -59,6 +59,7 @@ static seh_context *seh_ctx = NULL;
static seh_context *seh_ctx_cur = NULL;
/* Write xdata for arm, sh3, sh4, and ppc. */
static void
seh_write_text_eh_data (const char *hnd, const char *hnd_data)
{
@ -175,6 +176,7 @@ seh_arm_create_pdata (seh_context *c, unsigned char *data, size_t pdata_offs)
valueT func_len = 0;
valueT prolog_len = 0;
valueT start_len = 0;
func_len = resolve_symbol_value (c->end_addr);
start_len = resolve_symbol_value (c->start_addr);
if (c->endprologue_addr)
@ -209,7 +211,7 @@ seh_arm_write_pdata (void)
bfd *abfd = stdoutput;
h = seh_ctx_root;
if (h->done)
if (h == NULL || h->done)
return;
while (h != NULL)
{
@ -267,6 +269,7 @@ static void
seh_x64_make_prologue_element (int kind, int reg, bfd_vma off)
{
seh_prologue_element *n;
if (seh_ctx_cur == NULL)
return;
if (seh_ctx_cur->elems_count == seh_ctx_cur->elems_max)
@ -326,24 +329,23 @@ seh_x64_read_reg (const char *tok, int kind, int *regno)
default:
abort ();
}
if (*input_line_pointer == 0 || *input_line_pointer == '\n')
{
return 0;
}
if (*input_line_pointer == '%')
++input_line_pointer;
symbol_name = input_line_pointer;
name_end = get_symbol_end ();
for (i = 0; i < 16; i++)
{
if (! strcasecmp (p[i], symbol_name))
break;
}
if (i == 16)
{
as_warn (_("In %s we found the invalid register name %s.\n"),
tok, symbol_name);
}
*input_line_pointer = name_end;
while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
input_line_pointer++;
@ -656,13 +658,14 @@ obj_coff_seh_push (int what)
{
int reg = 0;
int kind = -1;
if (seh_ctx_cur == NULL)
{
as_warn (_(".seh_push used outside of .seh_proc block.\n"));
demand_empty_rest_of_line ();
return;
}
/* what 0:reg, 1:pushframe. */
/* What 0:reg, 1:pushframe. */
switch (what)
{
case 0:
@ -743,6 +746,7 @@ static void
obj_coff_seh_stack_alloc (int what ATTRIBUTE_UNUSED)
{
bfd_vma size;
if (seh_ctx_cur == NULL)
{
as_warn (_(".seh_stackalloc used outside of .seh_proc block.\n"));
@ -822,6 +826,7 @@ static void
seh_symbol_init (bfd *abfd, unsigned int added)
{
unsigned int oldcount;
oldcount = bfd_get_symcount (abfd);
symptr = oldcount;
symtab = xmalloc ((oldcount + added + 6) * sizeof (asymbol *));
@ -836,6 +841,7 @@ seh_symbol (bfd *abfd, const char *n1, const char *n2, const char *n3,
asymbol *sym;
char *name = xmalloc (strlen (n1) + strlen (n2) + strlen (n3) + 1);
int ret = symptr;
strcpy (name, n1);
strcat (name, n2);
strcat (name, n3);
@ -853,6 +859,7 @@ quick_section (bfd *abfd, const char *name, int flags, int align)
{
asection *sec;
asymbol *sym;
sec = seh_make_section2 (name, flags);
bfd_set_section_alignment (abfd, sec, align);
/* Remember to undo this before trying to link internally! */
@ -967,6 +974,7 @@ seh_make_xlbl_name (seh_context *c)
{
size_t len = strlen (".seh_xlbl_") + strlen (c->func_name) + 9 + 1;
char *ret = (char*) xmalloc (len);
if (!ret)
as_fatal (_("Out of memory for xdata lable for %s"), c->func_name);
else
@ -980,6 +988,7 @@ make_seh_text_label (seh_context *c, symbolS **addr)
{
char *sym_name;
size_t len = strlen (".seh_tlbl_") + strlen (c->func_name) + 9 + 1;
sym_name = (char *) xmalloc (len);
if (!sym_name)
as_fatal (_("Allocating memory for SEH's text symbol for %s failed"), c->func_name);
@ -1003,6 +1012,7 @@ seh_fill_pcsyms (const seh_context *c, char **names, int *idx)
valueT start_off = resolve_symbol_value (c->start_addr);
valueT un_off;
seh_prologue_element *e = c->elems;
names[0] = c->start_symbol;
idx[0] = 0;
if (c->elems_count == 0)
@ -1028,6 +1038,7 @@ seh_needed_unwind_info (seh_context *c)
valueT start_off = resolve_symbol_value (c->start_addr);
valueT un_off;
seh_prologue_element *e = c->elems;
if (c->elems_count == 0)
return count;
for (i = 0; i < c->elems_count; i++)
@ -1046,6 +1057,7 @@ static size_t
seh_getelm_data_size (const seh_context *c, int elm_start, int elm_end)
{
size_t ret = PEX64_UWI_SIZEOF_UWCODE_ARRAY (elm_end - elm_start);
while (elm_start < elm_end)
{
switch (c->elems[elm_start].kind)
@ -1078,6 +1090,7 @@ static size_t
seh_getsize_of_unwind_entry (seh_context *c, int elm_start, int elm_end, int bechain)
{
size_t ret = seh_getelm_data_size(c, elm_start, elm_end);
c->count_syms += 1;
if (bechain)
{
@ -1148,6 +1161,7 @@ seh_make_unwind_entry (const seh_context *c, char *name, int elm_start, int elm_
if (bechain)
{
char n[100];
sprintf (n,"%x", no);
idx = seh_symbol (c->abfd, ".xdata_fct", c->func_name, n, UNDSEC, BSF_GLOBAL, (int) off);
seh_reloc (c->abfd, off, BFD_RELOC_RVA, idx);
@ -1234,9 +1248,7 @@ seh_getsize_unwind_data (seh_context *c)
c->count_syms += 5 * need;
xdata_sz += (seh_getsize_of_unwind_entry (c, elm_start[0], elm_start[1], 1 != need) + 7) & ~7;
for (i = 1; i < need; i++)
{
xdata_sz += (seh_getsize_of_unwind_entry (c, elm_start[i], elm_start[i + 1], 1 != need) + 7) & ~7;
}
/* Create lable names for .xdata unwind info. */
names[0] = c->xdata_first;
@ -1259,16 +1271,14 @@ seh_create_unwind_data (seh_context *c, unsigned char *data, size_t offs)
int *elm_start = c->xdata_elm_start;
for (i = 1; i < need; i++)
{
seh_make_function_entry_xdata (c, pc_syms[i], c->end_symbol, names[i], data, &offs, i);
}
/* Generate the function entry. Remark, that just
first is in .pdata section and already emitted. */
seh_make_unwind_entry (c, c->xdata_first, elm_start[0], elm_start[1], 1 != need, data, &offs, 1);
for (i = 1; i < need; i++)
{
seh_make_unwind_entry (c, names[i], elm_start[i], elm_start[i + 1], (i + 1) != need, data, &offs, i + 1);
}
for (i = 1; i < need; i++)
free (names[i]);
free (names);
@ -1285,6 +1295,7 @@ seh_make_function_entry_xdata (seh_context *c, char *pc_start, char *pc_end, cha
bfd_vma addr = (bfd_vma) *poffs;
int idx;
char s[100];
if (!data)
return;
sprintf (s,"%x",no);
@ -1303,6 +1314,7 @@ seh_x64_makescope_elem (seh_context *c, const char *begin, const char *end,
const char *handler, const char *jmp)
{
seh_scope_elem *r;
if (!end || !begin)
return NULL;
if (c->scope_count >= c->scope_max)