This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld crash in vinfo
Hi Shaun,
> This crashes for me.
>
> cat > hello.def <<EOF
> LIBRARY hello
> STACKSIZE 0x100000, 0x1000
> HEAPSIZE 0x100000, 0x1000
> EXPORTS
> _hello
> EOF
> arm-wince-pe-gcc -nostdlib -e _DllMain -Wl,--dll -Wl,--subsystem=wince:3.00 -Wl,--base-file=hello.base -o hello.dll -lsupc++ -lm -lc -lgcc
> arm-wince-pe-dlltool -D hello.dll -d hello.def -b hello.base -e hello.exp
> arm-wince-pe-gcc -nostdlib -e _DllMain -Wl,--dll -Wl,--subsystem=wince:3.00 -Wl,--base-file=hello.base -o hello.dll hello.exp -lsupc++ -lm -lc -lgcc
>
> I'm interested in knowing if you see the same thing.
I do indeed. This test case exposed several bugs in the linker's
.def file parser. The attached patch should fix them though. Please
could you try it out and let me know if it works ?
Cheers
Nick
2003-06-26 Nick Clifton <nickc@redhat.com>
* deffilep.y (def_file_add_directive): Cope with NUL seperated
directives. Fix reporting of unparseable directives.
(def_error): Check for a NULL def_filename.
Index: deffilep.y
===================================================================
RCS file: /cvs/src/src/ld/deffilep.y,v
retrieving revision 1.14
diff -c -3 -p -r1.14 deffilep.y
*** deffilep.y 18 Mar 2003 21:33:43 -0000 1.14
--- deffilep.y 26 Jun 2003 16:56:46 -0000
*************** def_file_add_directive (my_def, param, l
*** 601,618 ****
{
def_file *save_def = def;
const char *pend = param + len;
! const char *tend = param;
int i;
def = my_def;
while (param < pend)
{
! while (param < pend && ISSPACE (*param))
param++;
! for (tend = param + 1;
! tend < pend && !(ISSPACE (tend[-1]) && *tend == '-');
tend++)
;
--- 601,626 ----
{
def_file *save_def = def;
const char *pend = param + len;
! char * tend = (char *) param;
int i;
def = my_def;
while (param < pend)
{
! while (param < pend && (ISSPACE (*param) || * param == '\n' || * param == 0))
param++;
! if (param == pend)
! break;
!
! /* Scan forward until we encounter any of:
! - the end of the buffer
! - the start of a new option
! - a newline seperating options
! - a NUL seperating options. */
! for (tend = (char *) (param + 1);
! tend < pend && !(ISSPACE (tend[-1]) && *tend == '-') && (*tend != '\n') && (*tend != 0);
tend++)
;
*************** def_file_add_directive (my_def, param, l
*** 628,642 ****
lex_parse_string = param + len + 1;
lex_forced_token = diropts[i].token;
saw_newline = 0;
! def_parse ();
break;
}
}
if (!diropts[i].param)
! /* xgettext:c-format */
! einfo (_("Warning: .drectve `%.*s' unrecognized\n"),
! tend - param, param);
lex_parse_string = 0;
param = tend;
--- 636,657 ----
lex_parse_string = param + len + 1;
lex_forced_token = diropts[i].token;
saw_newline = 0;
! if (def_parse ())
! continue;
break;
}
}
if (!diropts[i].param)
! {
! char saved;
!
! saved = * tend;
! * tend = 0;
! /* xgettext:c-format */
! einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
! * tend = saved;
! }
lex_parse_string = 0;
param = tend;
*************** static int
*** 843,849 ****
def_error (err)
const char *err;
{
! einfo ("%P: %s:%d: %s\n", def_filename, linenumber, err);
return 0;
}
--- 858,864 ----
def_error (err)
const char *err;
{
! einfo ("%P: %s:%d: %s\n", def_filename ? def_filename : "<unknown-file>", linenumber, err);
return 0;
}