diff options
author | Alan Modra <amodra@gmail.com> | 2001-08-01 02:27:11 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2001-08-01 02:27:11 +0000 |
commit | 28f815927f4195aff9d5af22697b4faab3dac6e3 (patch) | |
tree | 673ae45815e97c84cd733e2b39e64babb0cfb554 /gas/config | |
parent | af08bab843d1cd0b056ad831e0d1b158a711fd44 (diff) | |
download | gdb-28f815927f4195aff9d5af22697b4faab3dac6e3.zip gdb-28f815927f4195aff9d5af22697b4faab3dac6e3.tar.gz gdb-28f815927f4195aff9d5af22697b4faab3dac6e3.tar.bz2 |
* config/tc-i386.c (lex_got): Match lower case relocation tokens.
Don't allocate more space than necessary for the input line copy.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-i386.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index bea0f4d..275b3e6 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -3181,27 +3181,41 @@ lex_got (reloc, adjust) int len; len = strlen (gotrel[j].str); - if (strncmp (cp + 1, gotrel[j].str, len) == 0) + if (strncasecmp (cp + 1, gotrel[j].str, len) == 0) { if (gotrel[j].rel[(unsigned int) flag_code] != 0) { - int first; - char *tmpbuf; + int first, second; + char *tmpbuf, *past_reloc; *reloc = gotrel[j].rel[(unsigned int) flag_code]; + if (adjust) + *adjust = len; if (GOT_symbol == NULL) GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME); /* Replace the relocation token with ' ', so that errors like foo@GOTOFF1 will be detected. */ + + /* The length of the first part of our input line. */ first = cp - input_line_pointer; - tmpbuf = xmalloc (strlen (input_line_pointer)); + + /* The second part goes from after the reloc token until + (and including) an end_of_line char. Don't use strlen + here as the end_of_line char may not be a NUL. */ + past_reloc = cp + 1 + len; + for (cp = past_reloc; !is_end_of_line[(unsigned char) *cp++]; ) + ; + second = cp - past_reloc; + + /* Allocate and copy string. The trailing NUL shouldn't + be necessary, but be safe. */ + tmpbuf = xmalloc (first + second + 2); memcpy (tmpbuf, input_line_pointer, first); tmpbuf[first] = ' '; - strcpy (tmpbuf + first + 1, cp + 1 + len); - if (adjust) - *adjust = len; + memcpy (tmpbuf + first + 1, past_reloc, second); + tmpbuf[first + second + 1] = '\0'; return tmpbuf; } |