From d038301c195742daa0008b68ee50e59ec151829e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 24 Apr 2003 17:15:25 +0000 Subject: [PATCH] 2003-04-24 Roland McGrath * 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. --- ld/ldgram.y | 62 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/ld/ldgram.y b/ld/ldgram.y index fadc3e5..e9c8a9f 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" #include "bfdlink.h" -#include "ld.h" +#include "ld.h" #include "ldexp.h" #include "ldver.h" #include "ldlang.h" @@ -102,7 +102,7 @@ static int error_index; %type memspec_at_opt %type wildcard_name %type wildcard_spec -%token INT +%token INT %token NAME LNAME %type length %type phdr_qualifiers @@ -110,7 +110,7 @@ static int error_index; %type phdr_opt %type opt_nocrossrefs -%right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ +%right PLUSEQ MINUSEQ MULTEQ DIVEQ '=' LSHIFTEQ RSHIFTEQ ANDEQ OREQ %right '?' ':' %left OROR %left ANDAND @@ -125,7 +125,7 @@ static int error_index; %left '*' '/' '%' %right UNARY -%token END +%token END %left '(' %token ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE %token SECTIONS PHDRS SORT DATA_SEGMENT_ALIGN DATA_SEGMENT_END @@ -158,7 +158,7 @@ static int error_index; %% -file: +file: INPUT_SCRIPT script_file | INPUT_MRI_SCRIPT mri_script_file | INPUT_VERSION_SCRIPT version_script_file @@ -178,7 +178,7 @@ defsym_expr: } ; -/* SYNTAX WITHIN AN MRI SCRIPT FILE */ +/* SYNTAX WITHIN AN MRI SCRIPT FILE */ mri_script_file: { ldlex_mri_script (); @@ -198,7 +198,7 @@ mri_script_lines: ; mri_script_command: - CHIP exp + CHIP exp | CHIP exp ',' exp | NAME { einfo(_("%P%F: unrecognised keyword in MRI style script '%s'\n"),$1); @@ -207,12 +207,12 @@ mri_script_command: config.map_filename = "-"; } | ORDER ordernamelist - | ENDWORD + | ENDWORD | PUBLIC NAME '=' exp { mri_public($2, $4); } | PUBLIC NAME ',' exp { mri_public($2, $4); } - | PUBLIC NAME exp + | PUBLIC NAME exp { mri_public($2, $3); } | FORMAT NAME { mri_format($2); } @@ -232,8 +232,8 @@ mri_script_command: { mri_alignmod($2,$4); } | ABSOLUTE mri_abs_name_list | LOAD mri_load_name_list - | NAMEWORD NAME - { mri_name($2); } + | NAMEWORD NAME + { mri_name($2); } | ALIAS NAME ',' NAME { mri_alias($2,$4,0);} | ALIAS NAME ',' INT @@ -340,7 +340,7 @@ ifile_p1: { lang_leave_group (); } | MAP '(' filename ')' { lang_add_map($3); } - | INCLUDE filename + | INCLUDE filename { ldlex_script (); ldfile_open_command_file($2); } ifile_list END { ldlex_popstate (); } @@ -439,7 +439,7 @@ exclude_name_list: tmp = (struct name_list *) xmalloc (sizeof *tmp); tmp->name = $2; tmp->next = $1; - $$ = tmp; + $$ = tmp; } | wildcard_name @@ -503,13 +503,13 @@ statement: assignment end | CREATE_OBJECT_SYMBOLS { - lang_add_attribute(lang_object_symbols_statement_enum); + lang_add_attribute(lang_object_symbols_statement_enum); } | ';' | CONSTRUCTORS { - - lang_add_attribute(lang_constructors_statement_enum); + + lang_add_attribute(lang_constructors_statement_enum); } | SORT '(' CONSTRUCTORS ')' { @@ -521,7 +521,7 @@ statement: { lang_add_data ((int) $1, $3); } - + | FILL '(' fill_exp ')' { lang_add_fill ($3); @@ -532,7 +532,7 @@ statement_list: statement_list statement | statement ; - + statement_list_opt: /* empty */ | statement_list @@ -701,7 +701,7 @@ floating_point_support: | NOFLOAT { lang_float(FALSE); } ; - + nocrossref_list: /* empty */ { @@ -829,7 +829,7 @@ opt_at: ; section: NAME { ldlex_expression(); } - opt_exp_with_type + opt_exp_with_type opt_at { ldlex_popstate (); ldlex_script (); } '{' { @@ -837,7 +837,7 @@ section: NAME { ldlex_expression(); } sectype, 0, 0, 0, $4); } - statement_list_opt + statement_list_opt '}' { ldlex_popstate (); ldlex_expression (); } memspec_opt memspec_at_opt phdr_opt fill_opt { @@ -850,7 +850,7 @@ section: NAME { ldlex_expression(); } { ldlex_expression (); } opt_exp_without_type opt_nocrossrefs opt_at { ldlex_popstate (); ldlex_script (); } - '{' + '{' { lang_enter_overlay ($3); } @@ -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); + } + } } } ; @@ -1159,9 +1171,9 @@ opt_semicolon: %% void -yyerror(arg) +yyerror(arg) const char *arg; -{ +{ if (ldfile_assumed_script) einfo (_("%P:%s: file format not recognized; treating as linker script\n"), ldfile_input_filename); -- 2.7.4