* ld crash when PHDRS uses undefined names
@ 2003-04-23 8:41 Roland McGrath
2003-04-24 12:52 ` Nick Clifton
0 siblings, 1 reply; 3+ messages in thread
From: Roland McGrath @ 2003-04-23 8:41 UTC (permalink / raw)
To: binutils
If a PHDRS statement uses unrecognized names for phdr types, ld crashes.
A test case is easy to concoct. This patch makes unrecognized names a
graceful error, and also makes it grok the recently added PT_* names.
I put the literal value for PT_GNU_EH_FRAME in there instead of futzing
with header inclusion, since it keeps the change simple and the array there
already implicits hard-codes literal values for the low-valued PT_* names.
The "$$ = exp_intop (0);" sets a bogus value when a bad name was diagnosed.
That prevents it from crashing later on. I don't know if there is a better
way to do it.
Someone gave me write access at some point, so I can commit with approval
if that is most convenient for whoever does the approving.
Thanks,
Roland
2003-04-23 Roland McGrath <roland@redhat.com>
* ldgram.y (phdr_type): Grok PT_TLS and PT_GNU_EH_FRAME names.
If a name string is unknown, give an error rather than crashing later.
--- binutils/ld/ldgram.y.~1.24.~ Fri Feb 28 12:22:01 2003
+++ binutils/ld/ldgram.y Wed Apr 23 01:32:20 2003
@@ -990,7 +990,7 @@ phdr_type:
{
"PT_NULL", "PT_LOAD", "PT_DYNAMIC",
"PT_INTERP", "PT_NOTE", "PT_SHLIB",
- "PT_PHDR"
+ "PT_PHDR", "PT_TLS"
};
s = $1->name.name;
@@ -1002,6 +1002,18 @@ phdr_type:
$$ = exp_intop (i);
break;
}
+ if (i == sizeof phdr_types / sizeof phdr_types[0])
+ {
+ if (strcmp (s, "PT_GNU_EH_FRAME") == 0)
+ $$ = exp_intop (0x6474e550);
+ else
+ {
+ einfo (_("\
+%X%P:%S: unknown phdr type `%s' (try integer literal)\n"),
+ s);
+ $$ = exp_intop (0);
+ }
+ }
}
}
;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ld crash when PHDRS uses undefined names
2003-04-23 8:41 ld crash when PHDRS uses undefined names Roland McGrath
@ 2003-04-24 12:52 ` Nick Clifton
2003-04-24 17:16 ` Roland McGrath
0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2003-04-24 12:52 UTC (permalink / raw)
To: Roland McGrath; +Cc: binutils
Hi Roland,
> 2003-04-23 Roland McGrath <roland@redhat.com>
>
> * ldgram.y (phdr_type): Grok PT_TLS and PT_GNU_EH_FRAME names.
> If a name string is unknown, give an error rather than crashing later.
Approved - please apply.
Note - it would be cleaner if the phdr_types[] table had a direct
mapping between the name and its integer value, so that you did not
have to have the special case code for the PT_GNU_EH_FRAME. Still
this is not a high priority change.
Cheers
Nick
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ld crash when PHDRS uses undefined names
2003-04-24 12:52 ` Nick Clifton
@ 2003-04-24 17:16 ` Roland McGrath
0 siblings, 0 replies; 3+ messages in thread
From: Roland McGrath @ 2003-04-24 17:16 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
> Approved - please apply.
Done.
> Note - it would be cleaner if the phdr_types[] table had a direct
> mapping between the name and its integer value, so that you did not
> have to have the special case code for the PT_GNU_EH_FRAME. Still
> this is not a high priority change.
I agree. But I was fixing a crash, not trying to improve the source,
so I just made the minimal necessary change.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-24 17:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23 8:41 ld crash when PHDRS uses undefined names Roland McGrath
2003-04-24 12:52 ` Nick Clifton
2003-04-24 17:16 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).