GNU Binutils with patches for OS216
修訂 | c44f198a3d152a2c6339289bfc81ca794c5aa31c (tree) |
---|---|
時間 | 2003-06-11 17:57:46 |
作者 | Jim Blandy <jimb@code...> |
Commiter | Jim Blandy |
* solib-svr4.c (bfd_lookup_symbol): New SECT_FLAGS argument.
(enable_break): Pass SEC_CODE as the SECT_FLAGS argument to
bfd_lookup_symbol, since we only want symbols in code sections.
(look_for_base): Pass zero as the SECT_FLAGS argument to
bfd_lookup_symbol, since we're not concerned about which section
the symbol is in.
@@ -159,7 +159,7 @@ static CORE_ADDR breakpoint_addr; /* Address where end bkpt is set */ | ||
159 | 159 | |
160 | 160 | static int match_main (char *); |
161 | 161 | |
162 | -static CORE_ADDR bfd_lookup_symbol (bfd *, char *); | |
162 | +static CORE_ADDR bfd_lookup_symbol (bfd *, char *, flagword); | |
163 | 163 | |
164 | 164 | /* |
165 | 165 |
@@ -169,7 +169,7 @@ static CORE_ADDR bfd_lookup_symbol (bfd *, char *); | ||
169 | 169 | |
170 | 170 | SYNOPSIS |
171 | 171 | |
172 | - CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname) | |
172 | + CORE_ADDR bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags) | |
173 | 173 | |
174 | 174 | DESCRIPTION |
175 | 175 |
@@ -178,12 +178,15 @@ static CORE_ADDR bfd_lookup_symbol (bfd *, char *); | ||
178 | 178 | shared library support to find the address of the debugger |
179 | 179 | interface structures in the shared library. |
180 | 180 | |
181 | + If SECT_FLAGS is non-zero, only match symbols in sections whose | |
182 | + flags include all those in SECT_FLAGS. | |
183 | + | |
181 | 184 | Note that 0 is specifically allowed as an error return (no |
182 | 185 | such symbol). |
183 | 186 | */ |
184 | 187 | |
185 | 188 | static CORE_ADDR |
186 | -bfd_lookup_symbol (bfd *abfd, char *symname) | |
189 | +bfd_lookup_symbol (bfd *abfd, char *symname, flagword sect_flags) | |
187 | 190 | { |
188 | 191 | long storage_needed; |
189 | 192 | asymbol *sym; |
@@ -204,7 +207,8 @@ bfd_lookup_symbol (bfd *abfd, char *symname) | ||
204 | 207 | for (i = 0; i < number_of_symbols; i++) |
205 | 208 | { |
206 | 209 | sym = *symbol_table++; |
207 | - if (STREQ (sym->name, symname)) | |
210 | + if (STREQ (sym->name, symname) | |
211 | + && (sym->section->flags & sect_flags) == sect_flags) | |
208 | 212 | { |
209 | 213 | /* Bfd symbols are section relative. */ |
210 | 214 | symaddr = sym->value + sym->section->vma; |
@@ -231,7 +235,9 @@ bfd_lookup_symbol (bfd *abfd, char *symname) | ||
231 | 235 | for (i = 0; i < number_of_symbols; i++) |
232 | 236 | { |
233 | 237 | sym = *symbol_table++; |
234 | - if (STREQ (sym->name, symname)) | |
238 | + | |
239 | + if (STREQ (sym->name, symname) | |
240 | + && (sym->section->flags & sect_flags) == sect_flags) | |
235 | 241 | { |
236 | 242 | /* Bfd symbols are section relative. */ |
237 | 243 | symaddr = sym->value + sym->section->vma; |
@@ -337,7 +343,7 @@ look_for_base (int fd, CORE_ADDR baseaddr) | ||
337 | 343 | |
338 | 344 | for (symbolp = debug_base_symbols; *symbolp != NULL; symbolp++) |
339 | 345 | { |
340 | - address = bfd_lookup_symbol (interp_bfd, *symbolp); | |
346 | + address = bfd_lookup_symbol (interp_bfd, *symbolp, 0); | |
341 | 347 | if (address != 0) |
342 | 348 | { |
343 | 349 | break; |
@@ -1039,7 +1045,16 @@ enable_break (void) | ||
1039 | 1045 | /* Now try to set a breakpoint in the dynamic linker. */ |
1040 | 1046 | for (bkpt_namep = solib_break_names; *bkpt_namep != NULL; bkpt_namep++) |
1041 | 1047 | { |
1042 | - sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep); | |
1048 | + /* On ABI's that use function descriptors, there are usually | |
1049 | + two linker symbols associated with each C function: one | |
1050 | + pointing at the actual entry point of the machine code, | |
1051 | + and one pointing at the function's descriptor. The | |
1052 | + latter symbol has the same name as the C function. | |
1053 | + | |
1054 | + What we're looking for here is the machine code entry | |
1055 | + point, so we are only interested in symbols in code | |
1056 | + sections. */ | |
1057 | + sym_addr = bfd_lookup_symbol (tmp_bfd, *bkpt_namep, SEC_CODE); | |
1043 | 1058 | if (sym_addr != 0) |
1044 | 1059 | break; |
1045 | 1060 | } |