From b804e4aff29e64c1cc5f923570fd6a4973e949b4 Mon Sep 17 00:00:00 2001 From: Kai Tietz Date: Tue, 11 May 2010 17:46:22 +0000 Subject: [PATCH] 2010-05-11 Kai Tietz * emultempl/pe.em (gld_${EMULATION_NAME}_before_parse): Initialize pe(p)_leading_underscore variable. (set_pe_name): Likewise. * emultempl/pep.em: Likewise. Additional change default to non-underscore for pep_leading_underscore equal to -1. --- ld/ChangeLog | 9 ++++++++ ld/emultempl/pe.em | 44 +++++++++++++++++++++++++++++++-------- ld/emultempl/pep.em | 50 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 84 insertions(+), 19 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 0accc60b4f..7fa12d771c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,12 @@ +2010-05-11 Kai Tietz + + * emultempl/pe.em (gld_${EMULATION_NAME}_before_parse): + Initialize pe(p)_leading_underscore variable. + (set_pe_name): Likewise. + * emultempl/pep.em: Likewise. + Additional change default to non-underscore for + pep_leading_underscore equal to -1. + 2010-05-07 Tristan Gingold * Makefile.in: Regenerate with automake 1.11.1. diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index ec893b9e5e..a1c5771297 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -145,6 +145,17 @@ extern const char *output_filename; static void gld_${EMULATION_NAME}_before_parse (void) { + int u; + /* Now we check target's default for getting proper symbol_char. */ + u = pe_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pe_leading_underscore = u; + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); output_filename = "${EXECUTABLE_NAME:-a.exe}"; #ifdef DLL_SUPPORT @@ -463,7 +474,17 @@ gld_${EMULATION_NAME}_list_options (FILE *file) static void set_pe_name (char *name, long val) { - int i; + int i, u; + + /* Now we check target's default for getting proper symbol_char. */ + u = pe_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pe_leading_underscore = u; /* Find the name and set it. */ for (i = 0; init[i].ptr; i++) @@ -530,15 +551,13 @@ set_entry_point (void) /* Now we check target's default for getting proper symbol_char. */ u = pe_leading_underscore; - if (u == -1 && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); - if (u == 0) - initial_symbol_char = ""; - else if (u != -1) - initial_symbol_char = "_"; - else + if (u == -1) abort (); + initial_symbol_char = (u == 1 ? "_" : ""); pe_leading_underscore = u; if (*initial_symbol_char != '\0') @@ -896,7 +915,16 @@ gld_${EMULATION_NAME}_set_symbols (void) { /* Run through and invent symbols for all the names and insert the defaults. */ - int j; + int j, u; + /* Now we check target's default for getting proper symbol_char. */ + u = pe_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pe_leading_underscore = u; if (!init[IMAGEBASEOFF].inited) { diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em index a315fd6343..a5b6464476 100644 --- a/ld/emultempl/pep.em +++ b/ld/emultempl/pep.em @@ -118,6 +118,17 @@ extern const char *output_filename; static void gld_${EMULATION_NAME}_before_parse (void) { + int u; + /* Now we check target's default for getting proper symbol_char. */ + u = pep_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pep_leading_underscore = u; + ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`); output_filename = "${EXECUTABLE_NAME:-a.exe}"; #ifdef DLL_SUPPORT @@ -286,16 +297,16 @@ typedef struct #define GET_INIT_SYMBOL_NAME(IDX) \ (init[(IDX)].symbol \ - + ((init[(IDX)].is_c_symbol == FALSE || pep_leading_underscore != 0) ? 0 : 1)) + + ((init[(IDX)].is_c_symbol == FALSE || pep_leading_underscore == 1) ? 0 : 1)) /* Decorates the C visible symbol by underscore, if target requires. */ #define U(CSTR) \ - (pep_leading_underscore == 0 ? CSTR : "_" CSTR) + (pep_leading_underscore != 1 ? CSTR : "_" CSTR) /* Get size of constant string for a possible underscore prefixed C visible symbol. */ #define U_SIZE(CSTR) \ - (sizeof (CSTR) + pep_leading_underscore == 0 ? 0 : 1) + (sizeof (CSTR) + pep_leading_underscore == 1 ? 0 : 1) #define D(field,symbol,def,usc) {&pep.field,sizeof(pep.field), def, symbol,0, usc} @@ -400,7 +411,17 @@ gld_${EMULATION_NAME}_list_options (FILE *file) static void set_pep_name (char *name, bfd_vma val) { - int i; + int i, u; + + /* Now we check target's default for getting proper symbol_char. */ + u = pep_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pep_leading_underscore = u; /* Find the name and set it. */ for (i = 0; init[i].ptr; i++) @@ -462,15 +483,13 @@ set_entry_point (void) /* Now we check target's default for getting proper symbol_char. */ u = pep_leading_underscore; - if (u == -1 && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); - if (u == 0) - initial_symbol_char = ""; - else if (u != -1) - initial_symbol_char = "_"; - else + if (u == -1) abort (); + initial_symbol_char = (u == 1 ? "_" : ""); pep_leading_underscore = u; if (*initial_symbol_char != '\0') @@ -821,7 +840,16 @@ gld_${EMULATION_NAME}_set_symbols (void) { /* Run through and invent symbols for all the names and insert the defaults. */ - int j; + int j, u; + /* Now we check target's default for getting proper symbol_char. */ + u = pep_leading_underscore; + if (u == -1 + && !bfd_get_target_info ("${OUTPUT_FORMAT}", NULL, NULL, &u, NULL)) + bfd_get_target_info ("${RELOCATEABLE_OUTPUT_FORMAT}", NULL, NULL, &u, NULL); + + if (u == -1) + abort (); + pep_leading_underscore = u; if (!init[IMAGEBASEOFF].inited) { -- 2.34.1