3.4.x系GCCをフロントエンドとするgnu chains
| Revision | b1e7490a55effdeb5ebe4f3930ce45c8c54fdec4 (tree) |
|---|---|
| Time | 2010-01-08 12:48:45 |
| Author | Masaki Muranaka <monaka@mona...> |
| Commiter | Masaki Muranaka |
Merge branch 'master' of git://github.com/monaka/binutils
| @@ -1,3 +1,8 @@ | ||
| 1 | +2010-01-07 H.J. Lu <hongjiu.lu@intel.com> | |
| 2 | + | |
| 3 | + PR ld/11143 | |
| 4 | + * elflink.c (elf_gc_sweep): Keep SHT_NOTE section. | |
| 5 | + | |
| 1 | 6 | 2010-01-04 Daniel Gutson <dgutson@codesourcery.com> |
| 2 | 7 | |
| 3 | 8 | * bfd.m4 (BFD_HAVE_SYS_PROCFS_TYPE): Define _STRUCTURE_PROC |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /* ELF linking support for BFD. |
| 2 | 2 | Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 3 | - 2005, 2006, 2007, 2008, 2009 | |
| 3 | + 2005, 2006, 2007, 2008, 2009, 2010 | |
| 4 | 4 | Free Software Foundation, Inc. |
| 5 | 5 | |
| 6 | 6 | This file is part of BFD, the Binary File Descriptor library. |
| @@ -11527,9 +11527,10 @@ elf_gc_sweep (bfd *abfd, struct bfd_link_info *info) | ||
| 11527 | 11527 | o->gc_mark = first->gc_mark; |
| 11528 | 11528 | } |
| 11529 | 11529 | else if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0 |
| 11530 | - || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0) | |
| 11530 | + || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0 | |
| 11531 | + || elf_section_data (o)->this_hdr.sh_type == SHT_NOTE) | |
| 11531 | 11532 | { |
| 11532 | - /* Keep debug and special sections. */ | |
| 11533 | + /* Keep debug, special and SHT_NOTE sections. */ | |
| 11533 | 11534 | o->gc_mark = 1; |
| 11534 | 11535 | } |
| 11535 | 11536 |
| @@ -1,3 +1,9 @@ | ||
| 1 | +2010-01-07 Tristan Gingold <gingold@adacore.com> | |
| 2 | + | |
| 3 | + * symfile.c (build_section_addr_info_from_objfile): New function. | |
| 4 | + (symbol_file_add_separate): Don't use offsets from objfile but | |
| 5 | + built an addr info. | |
| 6 | + | |
| 1 | 7 | 2010-01-06 Stan Shebs <stan@codesourcery.com> |
| 2 | 8 | |
| 3 | 9 | Support disconnected tracing. |
| @@ -384,6 +384,29 @@ build_section_addr_info_from_section_table (const struct target_section *start, | ||
| 384 | 384 | return sap; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | +/* Create a section_addr_info from section offsets in OBJFILE. */ | |
| 388 | + | |
| 389 | +static struct section_addr_info * | |
| 390 | +build_section_addr_info_from_objfile (const struct objfile *objfile) | |
| 391 | +{ | |
| 392 | + struct section_addr_info *sap; | |
| 393 | + int i; | |
| 394 | + struct bfd_section *sec; | |
| 395 | + | |
| 396 | + sap = alloc_section_addr_info (objfile->num_sections); | |
| 397 | + for (i = 0, sec = objfile->obfd->sections; | |
| 398 | + i < objfile->num_sections; | |
| 399 | + i++, sec = sec->next) | |
| 400 | + { | |
| 401 | + gdb_assert (sec != NULL); | |
| 402 | + sap->other[i].addr = (bfd_get_section_vma (objfile->obfd, sec) | |
| 403 | + + objfile->section_offsets->offsets[i]); | |
| 404 | + sap->other[i].name = xstrdup (bfd_get_section_name (objfile->obfd, sec)); | |
| 405 | + sap->other[i].sectindex = sec->index; | |
| 406 | + } | |
| 407 | + return sap; | |
| 408 | +} | |
| 409 | + | |
| 387 | 410 | |
| 388 | 411 | /* Free all memory allocated by build_section_addr_info_from_section_table. */ |
| 389 | 412 |
| @@ -1043,14 +1066,23 @@ void | ||
| 1043 | 1066 | symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile) |
| 1044 | 1067 | { |
| 1045 | 1068 | struct objfile *new_objfile; |
| 1069 | + struct section_addr_info *sap; | |
| 1070 | + struct cleanup *my_cleanup; | |
| 1071 | + | |
| 1072 | + /* Create section_addr_info. We can't directly use offsets from OBJFILE | |
| 1073 | + because sections of BFD may not match sections of OBJFILE and because | |
| 1074 | + vma may have been modified by tools such as prelink. */ | |
| 1075 | + sap = build_section_addr_info_from_objfile (objfile); | |
| 1076 | + my_cleanup = make_cleanup_free_section_addr_info (sap); | |
| 1046 | 1077 | |
| 1047 | 1078 | new_objfile = symbol_file_add_with_addrs_or_offsets |
| 1048 | 1079 | (bfd, symfile_flags, |
| 1049 | - 0, /* No addr table. */ | |
| 1050 | - objfile->section_offsets, objfile->num_sections, | |
| 1080 | + sap, NULL, 0, | |
| 1051 | 1081 | objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW |
| 1052 | 1082 | | OBJF_USERLOADED)); |
| 1053 | 1083 | |
| 1084 | + do_cleanups (my_cleanup); | |
| 1085 | + | |
| 1054 | 1086 | add_separate_debug_objfile (new_objfile, objfile); |
| 1055 | 1087 | } |
| 1056 | 1088 |
| @@ -1,3 +1,34 @@ | ||
| 1 | +2010-01-07 Ian Lance Taylor <iant@google.com> | |
| 2 | + | |
| 3 | + PR 10980 | |
| 4 | + * options.h (class General_options): Add --warn-unresolved-symbols | |
| 5 | + and --error-unresolved-symbols. | |
| 6 | + * errors.cc (Errors::undefined_symbol): Implement | |
| 7 | + --warn-unresolved-symbols. | |
| 8 | + | |
| 9 | + * options.h (class General_options): Add -z text and -z textoff. | |
| 10 | + * layout.cc (Layout::finish_dynamic_section): Implement -z text. | |
| 11 | + | |
| 12 | +2010-01-06 Sriraman Tallam <tmsriram@google.com> | |
| 13 | + | |
| 14 | + * gc.h (Garbage_collection::Cident_section_map): New typedef. | |
| 15 | + (Garbage_collection::cident_sections): New function. | |
| 16 | + (Garbage_collection::add_cident_section): New function. | |
| 17 | + (Garbage_collection::cident_sections_): New member. | |
| 18 | + (gc_process_relocs): Add references to sections whose names are C | |
| 19 | + identifiers. | |
| 20 | + * gold.h (cident_section_start_prefix): New constant. | |
| 21 | + (cident_section_stop_prefix): New constant. | |
| 22 | + (is_cident): New function. | |
| 23 | + * layout.cc (Layout::define_section_symbols): Replace string constants | |
| 24 | + with the newly defined constants. | |
| 25 | + * object.cc (Sized_relobj::do_layout): Track sections whose names are | |
| 26 | + C identifiers. | |
| 27 | + * testsuite/Makefile.am: Add gc_orphan_section_test. | |
| 28 | + * testsuite/Makefile.in: Regenerate. | |
| 29 | + * testsuite/gc_orphan_section_test.cc: New file. | |
| 30 | + * testsuite/gc_orphan_section_test.sh: New file. | |
| 31 | + | |
| 1 | 32 | 2010-01-06 Ian Lance Taylor <iant@google.com> |
| 2 | 33 | |
| 3 | 34 | PR 10980 |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // errors.cc -- handle errors for gold |
| 2 | 2 | |
| 3 | -// Copyright 2006, 2007, 2008 Free Software Foundation, Inc. | |
| 3 | +// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | |
| 4 | 4 | // Written by Ian Lance Taylor <iant@google.com>. |
| 5 | 5 | |
| 6 | 6 | // This file is part of gold. |
| @@ -156,21 +156,33 @@ Errors::undefined_symbol(const Symbol* sym, const std::string& location) | ||
| 156 | 156 | { |
| 157 | 157 | bool initialized = this->initialize_lock(); |
| 158 | 158 | gold_assert(initialized); |
| 159 | + | |
| 160 | + const char* zmsg; | |
| 159 | 161 | { |
| 160 | 162 | Hold_lock h(*this->lock_); |
| 161 | 163 | if (++this->undefined_symbols_[sym] >= max_undefined_error_report) |
| 162 | 164 | return; |
| 163 | - ++this->error_count_; | |
| 165 | + if (parameters->options().warn_unresolved_symbols()) | |
| 166 | + { | |
| 167 | + ++this->warning_count_; | |
| 168 | + zmsg = _("warning"); | |
| 169 | + } | |
| 170 | + else | |
| 171 | + { | |
| 172 | + ++this->error_count_; | |
| 173 | + zmsg = _("error"); | |
| 174 | + } | |
| 164 | 175 | } |
| 176 | + | |
| 165 | 177 | const char* const version = sym->version(); |
| 166 | 178 | if (version == NULL) |
| 167 | - fprintf(stderr, _("%s: %s: error: undefined reference to '%s'\n"), | |
| 168 | - this->program_name_, location.c_str(), | |
| 179 | + fprintf(stderr, _("%s: %s: %s: undefined reference to '%s'\n"), | |
| 180 | + this->program_name_, location.c_str(), zmsg, | |
| 169 | 181 | sym->demangled_name().c_str()); |
| 170 | 182 | else |
| 171 | 183 | fprintf(stderr, |
| 172 | - _("%s: %s: error: undefined reference to '%s', version '%s'\n"), | |
| 173 | - this->program_name_, location.c_str(), | |
| 184 | + _("%s: %s: %s: undefined reference to '%s', version '%s'\n"), | |
| 185 | + this->program_name_, location.c_str(), zmsg, | |
| 174 | 186 | sym->demangled_name().c_str(), version); |
| 175 | 187 | } |
| 176 | 188 |
| @@ -60,6 +60,10 @@ class Garbage_collection | ||
| 60 | 60 | typedef Unordered_set<Section_id, Section_id_hash> Sections_reachable; |
| 61 | 61 | typedef std::map<Section_id, Sections_reachable> Section_ref; |
| 62 | 62 | typedef std::queue<Section_id> Worklist_type; |
| 63 | + // This maps the name of the section which can be represented as a C | |
| 64 | + // identifier (cident) to the list of sections that have that name. | |
| 65 | + // Different object files can have cident sections with the same name. | |
| 66 | + typedef std::map<std::string, Sections_reachable> Cident_section_map; | |
| 63 | 67 | |
| 64 | 68 | Garbage_collection() |
| 65 | 69 | : is_worklist_ready_(false) |
| @@ -94,12 +98,23 @@ class Garbage_collection | ||
| 94 | 98 | is_section_garbage(Object* obj, unsigned int shndx) |
| 95 | 99 | { return (this->referenced_list().find(Section_id(obj, shndx)) |
| 96 | 100 | == this->referenced_list().end()); } |
| 101 | + | |
| 102 | + Cident_section_map* | |
| 103 | + cident_sections() | |
| 104 | + { return &cident_sections_; } | |
| 105 | + | |
| 106 | + void | |
| 107 | + add_cident_section(std::string section_name, | |
| 108 | + Section_id secn) | |
| 109 | + { this->cident_sections_[section_name].insert(secn); } | |
| 110 | + | |
| 97 | 111 | private: |
| 98 | 112 | |
| 99 | 113 | Worklist_type work_list_; |
| 100 | 114 | bool is_worklist_ready_; |
| 101 | 115 | Section_ref section_reloc_map_; |
| 102 | 116 | Sections_reachable referenced_list_; |
| 117 | + Cident_section_map cident_sections_; | |
| 103 | 118 | }; |
| 104 | 119 | |
| 105 | 120 | // Data to pass between successive invocations of do_layout |
| @@ -161,6 +176,7 @@ gc_process_relocs( | ||
| 161 | 176 | std::vector<Symbol*>* symvec = NULL; |
| 162 | 177 | std::vector<std::pair<long long, long long> >* addendvec = NULL; |
| 163 | 178 | bool is_icf_tracked = false; |
| 179 | + const char* cident_section_name = NULL; | |
| 164 | 180 | |
| 165 | 181 | if (parameters->options().icf_enabled() |
| 166 | 182 | && is_section_foldable_candidate(src_obj->section_name(src_indx).c_str())) |
| @@ -218,6 +234,19 @@ gc_process_relocs( | ||
| 218 | 234 | if (!is_ordinary) |
| 219 | 235 | continue; |
| 220 | 236 | Section_id dst_id(dst_obj, dst_indx); |
| 237 | + // If the symbol name matches '__start_XXX' then the section with | |
| 238 | + // the C identifier like name 'XXX' should not be garbage collected. | |
| 239 | + // A similar treatment to symbols with the name '__stop_XXX'. | |
| 240 | + if (is_prefix_of(cident_section_start_prefix, gsym->name())) | |
| 241 | + { | |
| 242 | + cident_section_name = (gsym->name() | |
| 243 | + + strlen(cident_section_start_prefix)); | |
| 244 | + } | |
| 245 | + else if (is_prefix_of(cident_section_stop_prefix, gsym->name())) | |
| 246 | + { | |
| 247 | + cident_section_name = (gsym->name() | |
| 248 | + + strlen(cident_section_stop_prefix)); | |
| 249 | + } | |
| 221 | 250 | if (is_icf_tracked) |
| 222 | 251 | { |
| 223 | 252 | (*secvec).push_back(dst_id); |
| @@ -245,6 +274,23 @@ gc_process_relocs( | ||
| 245 | 274 | Garbage_collection::Sections_reachable& v(map_it->second); |
| 246 | 275 | v.insert(dst_id); |
| 247 | 276 | } |
| 277 | + if (cident_section_name != NULL) | |
| 278 | + { | |
| 279 | + Garbage_collection::Cident_section_map::iterator ele = | |
| 280 | + symtab->gc()->cident_sections()->find(std::string(cident_section_name)); | |
| 281 | + if (ele == symtab->gc()->cident_sections()->end()) | |
| 282 | + continue; | |
| 283 | + Garbage_collection::Sections_reachable& | |
| 284 | + v(symtab->gc()->section_reloc_map()[src_id]); | |
| 285 | + Garbage_collection::Sections_reachable& cident_secn(ele->second); | |
| 286 | + for (Garbage_collection::Sections_reachable::iterator it_v | |
| 287 | + = cident_secn.begin(); | |
| 288 | + it_v != cident_secn.end(); | |
| 289 | + ++it_v) | |
| 290 | + { | |
| 291 | + v.insert(*it_v); | |
| 292 | + } | |
| 293 | + } | |
| 248 | 294 | } |
| 249 | 295 | } |
| 250 | 296 | return; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // gold.h -- general definitions for gold -*- C++ -*- |
| 2 | 2 | |
| 3 | -// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc. | |
| 3 | +// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | |
| 4 | 4 | // Written by Ian Lance Taylor <iant@google.com>. |
| 5 | 5 | |
| 6 | 6 | // This file is part of gold. |
| @@ -349,6 +349,21 @@ is_prefix_of(const char* prefix, const char* str) | ||
| 349 | 349 | return strncmp(prefix, str, strlen(prefix)) == 0; |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | +const char* const cident_section_start_prefix = "__start_"; | |
| 353 | +const char* const cident_section_stop_prefix = "__stop_"; | |
| 354 | + | |
| 355 | +// Returns true if the name is a valid C identifier | |
| 356 | +inline bool | |
| 357 | +is_cident(const char* name) | |
| 358 | +{ | |
| 359 | + return (name[strspn(name, | |
| 360 | + ("0123456789" | |
| 361 | + "ABCDEFGHIJKLMNOPWRSTUVWXYZ" | |
| 362 | + "abcdefghijklmnopqrstuvwxyz" | |
| 363 | + "_"))] | |
| 364 | + == '\0'); | |
| 365 | +} | |
| 366 | + | |
| 352 | 367 | // We sometimes need to hash strings. Ideally we should use std::tr1::hash or |
| 353 | 368 | // __gnu_cxx::hash on some systems but there is no guarantee that either |
| 354 | 369 | // one is available. For portability, we define simple string hash functions. |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | // layout.cc -- lay out output file sections for gold |
| 2 | 2 | |
| 3 | -// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc. | |
| 3 | +// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | |
| 4 | 4 | // Written by Ian Lance Taylor <iant@google.com>. |
| 5 | 5 | |
| 6 | 6 | // This file is part of gold. |
| @@ -1232,16 +1232,13 @@ Layout::define_section_symbols(Symbol_table* symtab) | ||
| 1232 | 1232 | ++p) |
| 1233 | 1233 | { |
| 1234 | 1234 | const char* const name = (*p)->name(); |
| 1235 | - if (name[strspn(name, | |
| 1236 | - ("0123456789" | |
| 1237 | - "ABCDEFGHIJKLMNOPWRSTUVWXYZ" | |
| 1238 | - "abcdefghijklmnopqrstuvwxyz" | |
| 1239 | - "_"))] | |
| 1240 | - == '\0') | |
| 1235 | + if (is_cident(name)) | |
| 1241 | 1236 | { |
| 1242 | 1237 | const std::string name_string(name); |
| 1243 | - const std::string start_name("__start_" + name_string); | |
| 1244 | - const std::string stop_name("__stop_" + name_string); | |
| 1238 | + const std::string start_name(cident_section_start_prefix | |
| 1239 | + + name_string); | |
| 1240 | + const std::string stop_name(cident_section_stop_prefix | |
| 1241 | + + name_string); | |
| 1245 | 1242 | |
| 1246 | 1243 | symtab->define_in_output_data(start_name.c_str(), |
| 1247 | 1244 | NULL, // version |
| @@ -3356,8 +3353,10 @@ Layout::finish_dynamic_section(const Input_objects* input_objects, | ||
| 3356 | 3353 | odyn->add_constant(elfcpp::DT_TEXTREL, 0); |
| 3357 | 3354 | flags |= elfcpp::DF_TEXTREL; |
| 3358 | 3355 | |
| 3359 | - if (parameters->options().warn_shared_textrel() | |
| 3360 | - && parameters->options().shared()) | |
| 3356 | + if (parameters->options().text()) | |
| 3357 | + gold_error(_("read-only segment has dynamic relocations")); | |
| 3358 | + else if (parameters->options().warn_shared_textrel() | |
| 3359 | + && parameters->options().shared()) | |
| 3361 | 3360 | gold_warning(_("shared library text segment is not shareable")); |
| 3362 | 3361 | } |
| 3363 | 3362 | if (parameters->options().shared() && this->has_static_tls()) |
| @@ -1180,6 +1180,14 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab, | ||
| 1180 | 1180 | { |
| 1181 | 1181 | symtab->gc()->worklist().push(Section_id(this, i)); |
| 1182 | 1182 | } |
| 1183 | + // If the section name XXX can be represented as a C identifier | |
| 1184 | + // it cannot be discarded if there are references to | |
| 1185 | + // __start_XXX and __stop_XXX symbols. These need to be | |
| 1186 | + // specially handled. | |
| 1187 | + if (is_cident(name)) | |
| 1188 | + { | |
| 1189 | + symtab->gc()->add_cident_section(name, Section_id(this, i)); | |
| 1190 | + } | |
| 1183 | 1191 | } |
| 1184 | 1192 | |
| 1185 | 1193 | // When doing a relocatable link we are going to copy input |
| @@ -972,6 +972,14 @@ class General_options | ||
| 972 | 972 | N_("Warn if text segment is not shareable"), |
| 973 | 973 | N_("Do not warn if text segment is not shareable (default)")); |
| 974 | 974 | |
| 975 | + DEFINE_bool(warn_unresolved_symbols, options::TWO_DASHES, '\0', false, | |
| 976 | + N_("Report unresolved symbols as warnings"), | |
| 977 | + NULL); | |
| 978 | + DEFINE_bool_alias(error_unresolved_symbols, warn_unresolved_symbols, | |
| 979 | + options::TWO_DASHES, '\0', | |
| 980 | + N_("Report unresolved symbols as errors"), | |
| 981 | + NULL, true); | |
| 982 | + | |
| 975 | 983 | DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false, |
| 976 | 984 | N_("Include all archive contents"), |
| 977 | 985 | N_("Include only needed archive contents")); |
| @@ -1052,6 +1060,12 @@ class General_options | ||
| 1052 | 1060 | DEFINE_bool(relro, options::DASH_Z, '\0', false, |
| 1053 | 1061 | N_("Where possible mark variables read-only after relocation"), |
| 1054 | 1062 | N_("Don't mark variables read-only after relocation")); |
| 1063 | + DEFINE_bool(text, options::DASH_Z, '\0', false, | |
| 1064 | + N_("Do not permit relocations in read-only segments"), | |
| 1065 | + NULL); | |
| 1066 | + DEFINE_bool_alias(textoff, text, options::DASH_Z, '\0', | |
| 1067 | + N_("Permit relocations in read-only segments (default)"), | |
| 1068 | + NULL, true); | |
| 1055 | 1069 | |
| 1056 | 1070 | public: |
| 1057 | 1071 | typedef options::Dir_list Dir_list; |
| @@ -139,6 +139,16 @@ gc_tls_test:gc_tls_test.o gcctestdir/ld | ||
| 139 | 139 | gc_tls_test.stdout: gc_tls_test |
| 140 | 140 | $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout |
| 141 | 141 | |
| 142 | +check_SCRIPTS += gc_orphan_section_test.sh | |
| 143 | +check_DATA += gc_orphan_section_test.stdout | |
| 144 | +MOSTLYCLEANFILES += gc_orphan_section_test | |
| 145 | +gc_orphan_section_test.o: gc_orphan_section_test.cc | |
| 146 | + $(CXXCOMPILE) -O0 -c -g -o $@ $< | |
| 147 | +gc_orphan_section_test:gc_orphan_section_test.o gcctestdir/ld | |
| 148 | + $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_orphan_section_test.o | |
| 149 | +gc_orphan_section_test.stdout: gc_orphan_section_test | |
| 150 | + $(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout | |
| 151 | + | |
| 142 | 152 | check_SCRIPTS += icf_test.sh |
| 143 | 153 | check_DATA += icf_test.stdout |
| 144 | 154 | MOSTLYCLEANFILES += icf_test |
| @@ -57,6 +57,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ | ||
| 57 | 57 | # and --dynamic-list-cpp-typeinfo |
| 58 | 58 | @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = incremental_test.sh \ |
| 59 | 59 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.sh gc_tls_test.sh \ |
| 60 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.sh \ | |
| 60 | 61 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \ |
| 61 | 62 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \ |
| 62 | 63 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \ |
| @@ -82,6 +83,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ | ||
| 82 | 83 | @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = incremental_test.stdout \ |
| 83 | 84 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \ |
| 84 | 85 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \ |
| 86 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \ | |
| 85 | 87 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.stdout \ |
| 86 | 88 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \ |
| 87 | 89 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.stdout \ |
| @@ -103,7 +105,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ | ||
| 103 | 105 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout |
| 104 | 106 | @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_3 = incremental_test \ |
| 105 | 107 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \ |
| 106 | -@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_keep_unique_test \ | |
| 108 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test icf_test \ | |
| 109 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \ | |
| 107 | 110 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test \ |
| 108 | 111 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.dbg \ |
| 109 | 112 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/weak_undef_lib.so |
| @@ -2582,6 +2585,12 @@ uninstall-am: | ||
| 2582 | 2585 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o |
| 2583 | 2586 | @GCC_TRUE@@NATIVE_LINKER_TRUE@gc_tls_test.stdout: gc_tls_test |
| 2584 | 2587 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout |
| 2588 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_orphan_section_test.o: gc_orphan_section_test.cc | |
| 2589 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -g -o $@ $< | |
| 2590 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_orphan_section_test:gc_orphan_section_test.o gcctestdir/ld | |
| 2591 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_orphan_section_test.o | |
| 2592 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@gc_orphan_section_test.stdout: gc_orphan_section_test | |
| 2593 | +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) gc_orphan_section_test > gc_orphan_section_test.stdout | |
| 2585 | 2594 | @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc |
| 2586 | 2595 | @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< |
| 2587 | 2596 | @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld |
| @@ -0,0 +1,36 @@ | ||
| 1 | +// gc_orphan_section_test.cc -- a test case for gold | |
| 2 | + | |
| 3 | +// Copyright 2010 Free Software Foundation, Inc. | |
| 4 | +// Written by Sriraman Tallam <tmsriram@google.com>. | |
| 5 | + | |
| 6 | +// This file is part of gold. | |
| 7 | + | |
| 8 | +// This program is free software; you can redistribute it and/or modify | |
| 9 | +// it under the terms of the GNU General Public License as published by | |
| 10 | +// the Free Software Foundation; either version 3 of the License, or | |
| 11 | +// (at your option) any later version. | |
| 12 | + | |
| 13 | +// This program is distributed in the hope that it will be useful, | |
| 14 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | +// GNU General Public License for more details. | |
| 17 | + | |
| 18 | +// You should have received a copy of the GNU General Public License | |
| 19 | +// along with this program; if not, write to the Free Software | |
| 20 | +// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
| 21 | +// MA 02110-1301, USA. | |
| 22 | + | |
| 23 | +// The goal of this program is to verify if garbage collection does not | |
| 24 | +// discard orphan sections when references to them through __start_XXX | |
| 25 | +// and __stop_XXX are present. Here section _foo must not be gc'ed but | |
| 26 | +// _boo should be gc'ed. | |
| 27 | + | |
| 28 | +extern const int *__start__foo; | |
| 29 | +int foo __attribute__((__section__("_foo"))) = 1; | |
| 30 | +int boo __attribute__((__section__("_boo"))) = 1; | |
| 31 | + | |
| 32 | +int main() | |
| 33 | +{ | |
| 34 | + return *__start__foo; | |
| 35 | +} | |
| 36 | + |
| @@ -0,0 +1,46 @@ | ||
| 1 | +#!/bin/sh | |
| 2 | + | |
| 3 | +# gc_orphan_section_test.sh -- test --gc-sections | |
| 4 | + | |
| 5 | +# Copyright 2010 Free Software Foundation, Inc. | |
| 6 | +# Written by Sriraman Tallam <tmsriram@google.com>. | |
| 7 | + | |
| 8 | +# This file is part of gold. | |
| 9 | + | |
| 10 | +# This program is free software; you can redistribute it and/or modify | |
| 11 | +# it under the terms of the GNU General Public License as published by | |
| 12 | +# the Free Software Foundation; either version 3 of the License, or | |
| 13 | +# (at your option) any later version. | |
| 14 | + | |
| 15 | +# This program is distributed in the hope that it will be useful, | |
| 16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | +# GNU General Public License for more details. | |
| 19 | + | |
| 20 | +# You should have received a copy of the GNU General Public License | |
| 21 | +# along with this program; if not, write to the Free Software | |
| 22 | +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | |
| 23 | +# MA 02110-1301, USA. | |
| 24 | + | |
| 25 | +# The goal of this program is to verify if gc-sections works as expected | |
| 26 | +# with orphan sections. | |
| 27 | +# File gc_orphan_sections_test.cc is in this test. This program checks if | |
| 28 | +# the orphan sections are retained when they are referenced through | |
| 29 | +# __start_XXX and __stop_XXX symbols. | |
| 30 | + | |
| 31 | +check() | |
| 32 | +{ | |
| 33 | + if grep -q " boo" "$1" | |
| 34 | + then | |
| 35 | + echo "Garbage collection failed to collect boo" | |
| 36 | + exit 1 | |
| 37 | + fi | |
| 38 | + grep_foo=`grep -q " foo" $1` | |
| 39 | + if [ $? != 0 ]; | |
| 40 | + then | |
| 41 | + echo "Garbage collection should not discard foo" | |
| 42 | + exit 1 | |
| 43 | + fi | |
| 44 | +} | |
| 45 | + | |
| 46 | +check gc_orphan_section_test.stdout |
| @@ -1,3 +1,10 @@ | ||
| 1 | +2010-01-07 H.J. Lu <hongjiu.lu@intel.com> | |
| 2 | + | |
| 3 | + PR ld/11143 | |
| 4 | + * ld-gc/gc.exp: Run abi-note. | |
| 5 | + | |
| 6 | + * ld-gc/abi-note.d: New. | |
| 7 | + * ld-gc/abi-note.s: Likewise. | |
| 1 | 8 | |
| 2 | 9 | For older changes see ChangeLog-2009 |
| 3 | 10 |
| @@ -0,0 +1,8 @@ | ||
| 1 | +#name: --gc-sections with note section | |
| 2 | +#ld: --gc-sections -e _start | |
| 3 | +#readelf: -S --wide | |
| 4 | +#target: *-*-linux* | |
| 5 | + | |
| 6 | +#... | |
| 7 | +.* .note.ABI-tag[ ]+NOTE.* | |
| 8 | +#... |
| @@ -0,0 +1,15 @@ | ||
| 1 | + .text | |
| 2 | + .global _start | |
| 3 | +_start: | |
| 4 | + .long 1 | |
| 5 | + | |
| 6 | + .section ".note.ABI-tag", "a" | |
| 7 | + .p2align 2 | |
| 8 | + .long 1f - 0f /* name length */ | |
| 9 | + .long 3f - 2f /* data length */ | |
| 10 | + .long 1 /* note type */ | |
| 11 | +0: .asciz "GNU" /* vendor name */ | |
| 12 | +1: .p2align 2 | |
| 13 | +2: .long 1 | |
| 14 | + .long 2 | |
| 15 | +3: .p2align 2 /* pad out section */ |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | # Expect script for ld-gc tests |
| 2 | -# Copyright 2008, 2009 | |
| 2 | +# Copyright 2008, 2009, 2010 | |
| 3 | 3 | # Free Software Foundation, Inc. |
| 4 | 4 | # |
| 5 | 5 | # This file is part of the GNU Binutils. |
| @@ -90,3 +90,4 @@ test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main" | ||
| 90 | 90 | test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func" |
| 91 | 91 | |
| 92 | 92 | run_dump_test "noent" |
| 93 | +run_dump_test "abi-note" |
| @@ -1,3 +1,11 @@ | ||
| 1 | +2010-01-07 Doug Evans <dje@sebabeach.org> | |
| 2 | + | |
| 3 | + * cgen-ibld.in (insert_normal, extract_normal): Minor cleanup. | |
| 4 | + * fr30-ibld.c, * frv-ibld.c, * ip2k-ibld.c, * iq2000-ibld.c, | |
| 5 | + * lm32-ibld.c, * m32c-ibld.c, * m32r-ibld.c, * mep-ibld.c, | |
| 6 | + * mt-ibld.c, * openrisc-ibld.c, * xc16x-ibld.c, | |
| 7 | + * xstormy16-ibld.c: Regenerate. | |
| 8 | + | |
| 1 | 9 | 2010-01-06 Quentin Neill <quentin.neill@amd.com> |
| 2 | 10 | |
| 3 | 11 | * i386-gen.c (cpu_flag_init): Add new CPU_AMDFAM15_FLAGS. |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd, | ||
| 138 | 138 | if (length == 0) |
| 139 | 139 | return NULL; |
| 140 | 140 | |
| 141 | - if (word_length > 32) | |
| 141 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 142 | 142 | abort (); |
| 143 | 143 | |
| 144 | 144 | /* For architectures with insns smaller than the base-insn-bitsize, |
| @@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 442 | 442 | return 1; |
| 443 | 443 | } |
| 444 | 444 | |
| 445 | - if (word_length > 32) | |
| 445 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 446 | 446 | abort (); |
| 447 | 447 | |
| 448 | 448 | /* For architectures with insns smaller than the insn-base-bitsize, |
| @@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd, | ||
| 469 | 469 | { |
| 470 | 470 | unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; |
| 471 | 471 | |
| 472 | - if (word_length > 32) | |
| 472 | + if (word_length > 8 * sizeof (CGEN_INSN_INT)) | |
| 473 | 473 | abort (); |
| 474 | 474 | |
| 475 | 475 | if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) |
| @@ -1,3 +1,7 @@ | ||
| 1 | +2010-01-07 Corinna Vinschen <corinna@vinschen.de> | |
| 2 | + | |
| 3 | + * overview.sgml: Fix Red Hat brand name. | |
| 4 | + | |
| 1 | 5 | 2010-01-04 Christopher Faylor <me+cygwin@cgf.cx> |
| 2 | 6 | |
| 3 | 7 | * overview.sgml: Fix Red Hat URL. |
| @@ -48,7 +48,7 @@ library, you may want the Cygwin proprietary-use license. | ||
| 48 | 48 | For more information about the proprietary-use license, please go to |
| 49 | 49 | <ulink url="http://www.redhat.com/services/custom/cygwin/">http://www.redhat.com/services/custom/cygwin/</ulink>. |
| 50 | 50 | Customers of the native Win32 GNUPro should feel free to submit bug |
| 51 | -reports and ask questions through Red hat channels. All other | |
| 51 | +reports and ask questions through Red Hat channels. All other | |
| 52 | 52 | questions should be sent to the project mailing list |
| 53 | 53 | <email>cygwin@cygwin.com</email>.</para> |
| 54 | 54 |
| @@ -1,3 +1,15 @@ | ||
| 1 | +2010-01-07 Corinna Vinschen <corinna@vinschen.de> | |
| 2 | + | |
| 3 | + * cygpath.cc: Throughout, free obsolete path buffers. | |
| 4 | + | |
| 5 | +2010-01-07 Corinna Vinschen <corinna@vinschen.de> | |
| 6 | + | |
| 7 | + * cygpath.cc (main): Remove enforcing "en_US.UTF-8" locale. | |
| 8 | + Revert usage of argz functions when reading input from file and | |
| 9 | + simplify option usage. Allow only one option argument and use | |
| 10 | + the rest as filename argument to allow spaces in filenames. Restrict | |
| 11 | + processing special folder type options to one line. | |
| 12 | + | |
| 1 | 13 | 2009-12-17 Christopher Faylor <me+cygwin@cgf.cx> |
| 2 | 14 | |
| 3 | 15 | * ps.cc (main): Return 0 if pid found. |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /* cygpath.cc -- convert pathnames between Windows and Unix format |
| 2 | 2 | Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
| 3 | - 2006, 2007, 2008, 2009 Red Hat, Inc. | |
| 3 | + 2006, 2007, 2008, 2009, 2010 Red Hat, Inc. | |
| 4 | 4 | |
| 5 | 5 | This file is part of Cygwin. |
| 6 | 6 |
| @@ -16,7 +16,6 @@ details. */ | ||
| 16 | 16 | #include <wchar.h> |
| 17 | 17 | #include <locale.h> |
| 18 | 18 | #include <stdlib.h> |
| 19 | -#include <argz.h> | |
| 20 | 19 | #include <limits.h> |
| 21 | 20 | #include <getopt.h> |
| 22 | 21 | #include <windows.h> |
| @@ -30,7 +29,7 @@ details. */ | ||
| 30 | 29 | #include <ddk/ntifs.h> |
| 31 | 30 | #include "wide_path.h" |
| 32 | 31 | |
| 33 | -static const char version[] = "$Revision$"; | |
| 32 | +static const char version[] = "$Revision: 1.58 $"; | |
| 34 | 33 | |
| 35 | 34 | static char *prog_name; |
| 36 | 35 | static char *file_arg, *output_arg; |
| @@ -227,6 +226,7 @@ get_device_name (char *path) | ||
| 227 | 226 | a valid DOS device name, if prepended with "\\.\". Return that |
| 228 | 227 | valid DOS path. */ |
| 229 | 228 | ULONG len = RtlUnicodeStringToAnsiSize (&odi->ObjectName); |
| 229 | + free (ret); | |
| 230 | 230 | ret = (char *) malloc (len + 4); |
| 231 | 231 | strcpy (ret, "\\\\.\\"); |
| 232 | 232 | ans.Length = 0; |
| @@ -667,10 +667,18 @@ do_sysfolders (char option) | ||
| 667 | 667 | } |
| 668 | 668 | else |
| 669 | 669 | { |
| 670 | + char *tmp; | |
| 671 | + | |
| 670 | 672 | if (shortname_flag) |
| 671 | - buf = get_short_name (buf); | |
| 673 | + { | |
| 674 | + buf = get_short_name (tmp = buf); | |
| 675 | + free (tmp); | |
| 676 | + } | |
| 672 | 677 | if (mixed_flag) |
| 673 | - buf = get_mixed_name (buf); | |
| 678 | + { | |
| 679 | + buf = get_mixed_name (tmp = buf); | |
| 680 | + free (tmp); | |
| 681 | + } | |
| 674 | 682 | } |
| 675 | 683 | printf ("%s\n", buf); |
| 676 | 684 | } |
| @@ -696,8 +704,8 @@ report_mode (char *filename) | ||
| 696 | 704 | static void |
| 697 | 705 | do_pathconv (char *filename) |
| 698 | 706 | { |
| 699 | - char *buf; | |
| 700 | - wchar_t *buf2; | |
| 707 | + char *buf = NULL, *tmp; | |
| 708 | + wchar_t *buf2 = NULL; | |
| 701 | 709 | DWORD len; |
| 702 | 710 | ssize_t err; |
| 703 | 711 | cygwin_conv_path_t conv_func = |
| @@ -738,13 +746,23 @@ do_pathconv (char *filename) | ||
| 738 | 746 | { |
| 739 | 747 | if (err) |
| 740 | 748 | /* oops */; |
| 741 | - buf = get_device_paths (buf); | |
| 749 | + buf = get_device_paths (tmp = buf); | |
| 750 | + free (tmp); | |
| 742 | 751 | if (shortname_flag) |
| 743 | - buf = get_short_paths (buf); | |
| 752 | + { | |
| 753 | + buf = get_short_paths (tmp = buf); | |
| 754 | + free (tmp); | |
| 755 | + } | |
| 744 | 756 | if (longname_flag) |
| 745 | - buf = get_long_paths (buf); | |
| 757 | + { | |
| 758 | + buf = get_long_paths (tmp = buf); | |
| 759 | + free (tmp); | |
| 760 | + } | |
| 746 | 761 | if (mixed_flag) |
| 747 | - buf = get_mixed_name (buf); | |
| 762 | + { | |
| 763 | + buf = get_mixed_name (tmp = buf); | |
| 764 | + free (tmp); | |
| 765 | + } | |
| 748 | 766 | } |
| 749 | 767 | if (err) |
| 750 | 768 | { |
| @@ -766,11 +784,21 @@ do_pathconv (char *filename) | ||
| 766 | 784 | if (!unix_flag) |
| 767 | 785 | { |
| 768 | 786 | my_wcstombs (buf, buf2, 32768); |
| 769 | - buf = get_device_name (buf); | |
| 787 | + buf = get_device_name (tmp = buf); | |
| 788 | + free (tmp); | |
| 770 | 789 | if (shortname_flag) |
| 771 | - buf = get_short_name (buf); | |
| 790 | + { | |
| 791 | + buf = get_short_name (tmp = buf); | |
| 792 | + free (tmp); | |
| 793 | + } | |
| 772 | 794 | if (longname_flag) |
| 773 | - buf = get_long_name (buf, len); | |
| 795 | + { | |
| 796 | + buf = get_long_name (tmp = buf, len); | |
| 797 | + free (tmp); | |
| 798 | + } | |
| 799 | + /* buf gets moved into the array so we have to set tmp for later | |
| 800 | + freeing beforehand. */ | |
| 801 | + tmp = buf; | |
| 774 | 802 | if (strncmp (buf, "\\\\?\\", 4) == 0) |
| 775 | 803 | { |
| 776 | 804 | len = 4; |
| @@ -784,11 +812,18 @@ do_pathconv (char *filename) | ||
| 784 | 812 | } |
| 785 | 813 | } |
| 786 | 814 | if (mixed_flag) |
| 787 | - buf = get_mixed_name (buf); | |
| 815 | + { | |
| 816 | + buf = get_mixed_name (buf); | |
| 817 | + free (tmp); | |
| 818 | + } | |
| 788 | 819 | } |
| 789 | 820 | } |
| 790 | 821 | |
| 791 | 822 | puts (buf); |
| 823 | + if (buf2) | |
| 824 | + free (buf2); | |
| 825 | + if (buf) | |
| 826 | + free (buf); | |
| 792 | 827 | } |
| 793 | 828 | |
| 794 | 829 | static void |
| @@ -1029,10 +1064,7 @@ main (int argc, char **argv) | ||
| 1029 | 1064 | { |
| 1030 | 1065 | int o; |
| 1031 | 1066 | |
| 1032 | - /* Use locale from environment. If not set or set to "C", use UTF-8. */ | |
| 1033 | 1067 | setlocale (LC_CTYPE, ""); |
| 1034 | - if (!strcmp (setlocale (LC_CTYPE, NULL), "C")) | |
| 1035 | - setlocale (LC_CTYPE, "en_US.UTF-8"); | |
| 1036 | 1068 | prog_name = strrchr (argv[0], '/'); |
| 1037 | 1069 | if (!prog_name) |
| 1038 | 1070 | prog_name = strrchr (argv[0], '\\'); |
| @@ -1070,35 +1102,33 @@ main (int argc, char **argv) | ||
| 1070 | 1102 | |
| 1071 | 1103 | while (fgets (buf, sizeof (buf), fp)) |
| 1072 | 1104 | { |
| 1073 | - size_t azl = 0; | |
| 1074 | - int ac; | |
| 1075 | - char *az, **av; | |
| 1105 | + int ac = 0; | |
| 1106 | + char *av[4] = { NULL, NULL, NULL, NULL }; | |
| 1076 | 1107 | char *p = strchr (buf, '\n'); |
| 1077 | 1108 | if (p) |
| 1078 | 1109 | *p = '\0'; |
| 1079 | - if (argz_create_sep (buf, ' ', &az, &azl)) | |
| 1110 | + p = buf; | |
| 1111 | + av[ac++] = prog_name; | |
| 1112 | + av[ac++] = p; | |
| 1113 | + if (options_from_file_flag && *p == '-') | |
| 1080 | 1114 | { |
| 1081 | - perror ("cygpath"); | |
| 1082 | - exit (1); | |
| 1115 | + while (*p && !isspace (*p)) | |
| 1116 | + ++p; | |
| 1117 | + if (*p) | |
| 1118 | + { | |
| 1119 | + *p++ = '\0'; | |
| 1120 | + while (*p && isspace (*p)) | |
| 1121 | + ++p; | |
| 1122 | + av[ac++] = p; | |
| 1123 | + } | |
| 1124 | + o = do_options (ac, av, 1); | |
| 1083 | 1125 | } |
| 1084 | - if (!az) | |
| 1085 | - continue; | |
| 1086 | - ac = argz_count (az, azl) + 1; | |
| 1087 | - av = (char **) malloc ((ac + 1) * sizeof (char *)); | |
| 1088 | - if (!av) | |
| 1126 | + else | |
| 1089 | 1127 | { |
| 1090 | - perror ("cygpath"); | |
| 1091 | - exit (1); | |
| 1128 | + output_flag = 0; | |
| 1129 | + optind = 1; | |
| 1092 | 1130 | } |
| 1093 | - av[0] = prog_name; | |
| 1094 | - argz_extract (az, azl, av + 1); | |
| 1095 | - if (options_from_file_flag) | |
| 1096 | - o = do_options (ac, av, 1); | |
| 1097 | - else | |
| 1098 | - optind = 1; | |
| 1099 | 1131 | action (ac, av, o); |
| 1100 | - free (az); | |
| 1101 | - free (av); | |
| 1102 | 1132 | } |
| 1103 | 1133 | } |
| 1104 | 1134 | exit (0); |