X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf.c;h=be1cbc88e5774c0a0c353030f0ac7956cbc1e8ea;hb=052b35d2e72af7da1fadbc2a4afa416195435b63;hp=48762e16edd2b634810cfc958489264e01597087;hpb=6014cea70c1305fb555624516d3803c034e9dd0e;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf.c b/bfd/elf.c index 48762e16ed..be1cbc88e5 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -554,6 +554,7 @@ _bfd_elf_link_hash_newfunc (entry, table, string) ret->weakdef = NULL; ret->got_offset = (bfd_vma) -1; ret->plt_offset = (bfd_vma) -1; + ret->linker_section_pointer = (elf_linker_section_pointers_t *)0; ret->type = STT_NOTYPE; ret->elf_link_hash_flags = 0; } @@ -1911,7 +1912,9 @@ assign_file_positions_for_segments (abfd) else p->p_flags = 0; - if (p->p_type == PT_LOAD && m->count > 0) + if (p->p_type == PT_LOAD + && m->count > 0 + && (m->sections[0]->flags & SEC_LOAD) != 0) off += (m->sections[0]->vma - off) % bed->maxpagesize; if (m->count == 0) @@ -2019,15 +2022,18 @@ assign_file_positions_for_segments (abfd) /* The section VMA must equal the file position modulo the page size. */ - adjust = (sec->vma - off) % bed->maxpagesize; - if (adjust != 0) + if ((flags & SEC_LOAD) != 0) { - if (i == 0) - abort (); - p->p_memsz += adjust; - if ((flags & SEC_LOAD) != 0) - p->p_filesz += adjust; - off += adjust; + adjust = (sec->vma - off) % bed->maxpagesize; + if (adjust != 0) + { + if (i == 0) + abort (); + p->p_memsz += adjust; + if ((flags & SEC_LOAD) != 0) + p->p_filesz += adjust; + off += adjust; + } } sec->filepos = off; @@ -2831,6 +2837,7 @@ swap_out_syms (abfd, sttp) bfd_vma value = syms[idx]->value; elf_symbol_type *type_ptr; flagword flags = syms[idx]->flags; + int type; if (flags & BSF_SECTION_SYM) /* Section symbols have no names. */ @@ -2925,15 +2932,20 @@ swap_out_syms (abfd, sttp) sym.st_shndx = shndx; } + if ((flags & BSF_FUNCTION) != 0) + type = STT_FUNC; + else if ((flags & BSF_OBJECT) != 0) + type = STT_OBJECT; + else + type = STT_NOTYPE; + if (bfd_is_com_section (syms[idx]->section)) - sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_OBJECT); + sym.st_info = ELF_ST_INFO (STB_GLOBAL, type); else if (bfd_is_und_section (syms[idx]->section)) sym.st_info = ELF_ST_INFO (((flags & BSF_WEAK) ? STB_WEAK : STB_GLOBAL), - ((flags & BSF_FUNCTION) - ? STT_FUNC - : STT_NOTYPE)); + type); else if (flags & BSF_SECTION_SYM) sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION); else if (flags & BSF_FILE) @@ -2941,7 +2953,6 @@ swap_out_syms (abfd, sttp) else { int bind = STB_LOCAL; - int type = STT_OBJECT; if (flags & BSF_LOCAL) bind = STB_LOCAL; @@ -2950,9 +2961,6 @@ swap_out_syms (abfd, sttp) else if (flags & BSF_GLOBAL) bind = STB_GLOBAL; - if (flags & BSF_FUNCTION) - type = STT_FUNC; - sym.st_info = ELF_ST_INFO (bind, type); } @@ -3137,15 +3145,26 @@ _bfd_elf_find_nearest_line (abfd, CONST char **functionname_ptr; unsigned int *line_ptr; { + boolean found; const char *filename; asymbol *func; + bfd_vma low_func; asymbol **p; + if (! _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, + &found, filename_ptr, + functionname_ptr, line_ptr, + &elf_tdata (abfd)->line_info)) + return false; + if (found) + return true; + if (symbols == NULL) return false; filename = NULL; func = NULL; + low_func = 0; for (p = symbols; *p != NULL; p++) { @@ -3164,9 +3183,13 @@ _bfd_elf_find_nearest_line (abfd, filename = bfd_asymbol_name (&q->symbol); break; case STT_FUNC: - if (func == NULL - || q->symbol.value <= offset) - func = (asymbol *) q; + if (q->symbol.section == section + && q->symbol.value >= low_func + && q->symbol.value <= offset) + { + func = (asymbol *) q; + low_func = q->symbol.value; + } break; } }