Index: bfd/elf.c =================================================================== RCS file: /cvs/src/src/bfd/elf.c,v retrieving revision 1.329 diff -c -p -r1.329 elf.c *** bfd/elf.c 16 Mar 2006 12:20:15 -0000 1.329 --- bfd/elf.c 24 May 2006 12:52:58 -0000 *************** bfd_section_from_shdr (bfd *abfd, unsign *** 1935,1940 **** --- 1935,1941 ---- BFD_ASSERT (elf_symtab_shndx (abfd) == 0); elf_symtab_shndx (abfd) = shindex; elf_tdata (abfd)->symtab_shndx_hdr = *hdr; + elf_tdata (abfd)->symtab_shndx_section = shindex; elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->symtab_shndx_hdr; return TRUE; *************** bfd_section_from_shdr (bfd *abfd, unsign *** 1944,1949 **** --- 1945,1951 ---- if (ehdr->e_shstrndx == shindex) { elf_tdata (abfd)->shstrtab_hdr = *hdr; + elf_tdata (abfd)->shstrtab_section = shindex; elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->shstrtab_hdr; return TRUE; } *************** bfd_section_from_shdr (bfd *abfd, unsign *** 1951,1956 **** --- 1953,1959 ---- { symtab_strtab: elf_tdata (abfd)->strtab_hdr = *hdr; + elf_tdata (abfd)->strtab_section = shindex; elf_elfsections (abfd)[shindex] = &elf_tdata (abfd)->strtab_hdr; return TRUE; } Index: binutils/objcopy.c =================================================================== RCS file: /cvs/src/src/binutils/objcopy.c,v retrieving revision 1.95 diff -c -p -r1.95 objcopy.c *** binutils/objcopy.c 28 Feb 2006 16:09:01 -0000 1.95 --- binutils/objcopy.c 24 May 2006 12:52:58 -0000 *************** filter_symbols (bfd *abfd, bfd *obfd, as *** 915,920 **** --- 915,959 ---- || undefined || bfd_is_com_section (bfd_get_section (sym))) keep = strip_symbols != STRIP_UNNEEDED; + else if ((flags & BSF_SECTION_SYM) != 0) /* Section symbol. */ + { + struct bfd_section *section = sym->section; + + keep = 1; + + if (!bfd_is_abs_section (section) + && is_strip_section (abfd, section)) + keep = 0; + else if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) + { + Elf_Internal_Shdr **elfsections = elf_elfsections (abfd); + unsigned int sec; + + for (sec = 0; sec < elf_numsections (abfd); sec++) + { + Elf_Internal_Shdr *elfhdr = elfsections[sec]; + if ((elfhdr->sh_type == SHT_REL + || elfhdr->sh_type == SHT_RELA)) + { + char *secname = + bfd_elf_string_from_elf_section (abfd, + elf_elfheader (abfd)->e_shstrndx, + elfhdr->sh_name); + + if (strcmp (secname, name) == 0) + { + struct bfd_section *targsec = + bfd_section_from_elf_index (abfd, elfhdr->sh_info); + if (targsec && is_strip_section (abfd, targsec)) + { + keep = 0; + break; + } + } + } + } + } + } else if ((flags & BSF_DEBUGGING) != 0) /* Debugging symbol. */ keep = (strip_symbols != STRIP_DEBUG && strip_symbols != STRIP_UNNEEDED *************** filter_symbols (bfd *abfd, bfd *obfd, as *** 969,975 **** sym->flags |= BSF_GLOBAL; } ! to[dst_count++] = sym; } } --- 1008,1016 ---- sym->flags |= BSF_GLOBAL; } ! to[dst_count] = sym; ! bfd_copy_private_symbol_data (abfd, sym, obfd, to[dst_count]); ! dst_count++; } }