• R/O
  • HTTP
  • SSH
  • HTTPS

pf3gnuchains3x: Commit

3.4.x系GCCをフロントエンドとするgnu chains


Commit MetaInfo

Revisionb1e7490a55effdeb5ebe4f3930ce45c8c54fdec4 (tree)
Time2010-01-08 12:48:45
AuthorMasaki Muranaka <monaka@mona...>
CommiterMasaki Muranaka

Log Message

Merge branch 'master' of git://github.com/monaka/binutils

Change Summary

Incremental Difference

--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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+
16 2010-01-04 Daniel Gutson <dgutson@codesourcery.com>
27
38 * bfd.m4 (BFD_HAVE_SYS_PROCFS_TYPE): Define _STRUCTURE_PROC
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1,6 +1,6 @@
11 /* ELF linking support for BFD.
22 Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3- 2005, 2006, 2007, 2008, 2009
3+ 2005, 2006, 2007, 2008, 2009, 2010
44 Free Software Foundation, Inc.
55
66 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)
1152711527 o->gc_mark = first->gc_mark;
1152811528 }
1152911529 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)
1153111532 {
11532- /* Keep debug and special sections. */
11533+ /* Keep debug, special and SHT_NOTE sections. */
1153311534 o->gc_mark = 1;
1153411535 }
1153511536
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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+
17 2010-01-06 Stan Shebs <stan@codesourcery.com>
28
39 Support disconnected tracing.
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -384,6 +384,29 @@ build_section_addr_info_from_section_table (const struct target_section *start,
384384 return sap;
385385 }
386386
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+
387410
388411 /* Free all memory allocated by build_section_addr_info_from_section_table. */
389412
@@ -1043,14 +1066,23 @@ void
10431066 symbol_file_add_separate (bfd *bfd, int symfile_flags, struct objfile *objfile)
10441067 {
10451068 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);
10461077
10471078 new_objfile = symbol_file_add_with_addrs_or_offsets
10481079 (bfd, symfile_flags,
1049- 0, /* No addr table. */
1050- objfile->section_offsets, objfile->num_sections,
1080+ sap, NULL, 0,
10511081 objfile->flags & (OBJF_REORDERED | OBJF_SHARED | OBJF_READNOW
10521082 | OBJF_USERLOADED));
10531083
1084+ do_cleanups (my_cleanup);
1085+
10541086 add_separate_debug_objfile (new_objfile, objfile);
10551087 }
10561088
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -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+
132 2010-01-06 Ian Lance Taylor <iant@google.com>
233
334 PR 10980
--- a/gold/errors.cc
+++ b/gold/errors.cc
@@ -1,6 +1,6 @@
11 // errors.cc -- handle errors for gold
22
3-// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
3+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
44 // Written by Ian Lance Taylor <iant@google.com>.
55
66 // This file is part of gold.
@@ -156,21 +156,33 @@ Errors::undefined_symbol(const Symbol* sym, const std::string& location)
156156 {
157157 bool initialized = this->initialize_lock();
158158 gold_assert(initialized);
159+
160+ const char* zmsg;
159161 {
160162 Hold_lock h(*this->lock_);
161163 if (++this->undefined_symbols_[sym] >= max_undefined_error_report)
162164 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+ }
164175 }
176+
165177 const char* const version = sym->version();
166178 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,
169181 sym->demangled_name().c_str());
170182 else
171183 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,
174186 sym->demangled_name().c_str(), version);
175187 }
176188
--- a/gold/gc.h
+++ b/gold/gc.h
@@ -60,6 +60,10 @@ class Garbage_collection
6060 typedef Unordered_set<Section_id, Section_id_hash> Sections_reachable;
6161 typedef std::map<Section_id, Sections_reachable> Section_ref;
6262 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;
6367
6468 Garbage_collection()
6569 : is_worklist_ready_(false)
@@ -94,12 +98,23 @@ class Garbage_collection
9498 is_section_garbage(Object* obj, unsigned int shndx)
9599 { return (this->referenced_list().find(Section_id(obj, shndx))
96100 == 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+
97111 private:
98112
99113 Worklist_type work_list_;
100114 bool is_worklist_ready_;
101115 Section_ref section_reloc_map_;
102116 Sections_reachable referenced_list_;
117+ Cident_section_map cident_sections_;
103118 };
104119
105120 // Data to pass between successive invocations of do_layout
@@ -161,6 +176,7 @@ gc_process_relocs(
161176 std::vector<Symbol*>* symvec = NULL;
162177 std::vector<std::pair<long long, long long> >* addendvec = NULL;
163178 bool is_icf_tracked = false;
179+ const char* cident_section_name = NULL;
164180
165181 if (parameters->options().icf_enabled()
166182 && is_section_foldable_candidate(src_obj->section_name(src_indx).c_str()))
@@ -218,6 +234,19 @@ gc_process_relocs(
218234 if (!is_ordinary)
219235 continue;
220236 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+ }
221250 if (is_icf_tracked)
222251 {
223252 (*secvec).push_back(dst_id);
@@ -245,6 +274,23 @@ gc_process_relocs(
245274 Garbage_collection::Sections_reachable& v(map_it->second);
246275 v.insert(dst_id);
247276 }
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+ }
248294 }
249295 }
250296 return;
--- a/gold/gold.h
+++ b/gold/gold.h
@@ -1,6 +1,6 @@
11 // gold.h -- general definitions for gold -*- C++ -*-
22
3-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
44 // Written by Ian Lance Taylor <iant@google.com>.
55
66 // This file is part of gold.
@@ -349,6 +349,21 @@ is_prefix_of(const char* prefix, const char* str)
349349 return strncmp(prefix, str, strlen(prefix)) == 0;
350350 }
351351
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+
352367 // We sometimes need to hash strings. Ideally we should use std::tr1::hash or
353368 // __gnu_cxx::hash on some systems but there is no guarantee that either
354369 // one is available. For portability, we define simple string hash functions.
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -1,6 +1,6 @@
11 // layout.cc -- lay out output file sections for gold
22
3-// Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
3+// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
44 // Written by Ian Lance Taylor <iant@google.com>.
55
66 // This file is part of gold.
@@ -1232,16 +1232,13 @@ Layout::define_section_symbols(Symbol_table* symtab)
12321232 ++p)
12331233 {
12341234 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))
12411236 {
12421237 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);
12451242
12461243 symtab->define_in_output_data(start_name.c_str(),
12471244 NULL, // version
@@ -3356,8 +3353,10 @@ Layout::finish_dynamic_section(const Input_objects* input_objects,
33563353 odyn->add_constant(elfcpp::DT_TEXTREL, 0);
33573354 flags |= elfcpp::DF_TEXTREL;
33583355
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())
33613360 gold_warning(_("shared library text segment is not shareable"));
33623361 }
33633362 if (parameters->options().shared() && this->has_static_tls())
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -1180,6 +1180,14 @@ Sized_relobj<size, big_endian>::do_layout(Symbol_table* symtab,
11801180 {
11811181 symtab->gc()->worklist().push(Section_id(this, i));
11821182 }
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+ }
11831191 }
11841192
11851193 // When doing a relocatable link we are going to copy input
--- a/gold/options.h
+++ b/gold/options.h
@@ -972,6 +972,14 @@ class General_options
972972 N_("Warn if text segment is not shareable"),
973973 N_("Do not warn if text segment is not shareable (default)"));
974974
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+
975983 DEFINE_bool(whole_archive, options::TWO_DASHES, '\0', false,
976984 N_("Include all archive contents"),
977985 N_("Include only needed archive contents"));
@@ -1052,6 +1060,12 @@ class General_options
10521060 DEFINE_bool(relro, options::DASH_Z, '\0', false,
10531061 N_("Where possible mark variables read-only after relocation"),
10541062 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);
10551069
10561070 public:
10571071 typedef options::Dir_list Dir_list;
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -139,6 +139,16 @@ gc_tls_test:gc_tls_test.o gcctestdir/ld
139139 gc_tls_test.stdout: gc_tls_test
140140 $(TEST_NM) -C gc_tls_test > gc_tls_test.stdout
141141
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+
142152 check_SCRIPTS += icf_test.sh
143153 check_DATA += icf_test.stdout
144154 MOSTLYCLEANFILES += icf_test
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -57,6 +57,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
5757 # and --dynamic-list-cpp-typeinfo
5858 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = incremental_test.sh \
5959 @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.sh gc_tls_test.sh \
60+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.sh \
6061 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.sh \
6162 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.sh \
6263 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.sh \
@@ -82,6 +83,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
8283 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_2 = incremental_test.stdout \
8384 @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \
8485 @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \
86+@GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \
8587 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test.stdout \
8688 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \
8789 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.stdout \
@@ -103,7 +105,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
103105 @GCC_TRUE@@NATIVE_LINKER_TRUE@ dynamic_list.stdout
104106 @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_3 = incremental_test \
105107 @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 \
107110 @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test \
108111 @GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_shared.dbg \
109112 @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/weak_undef_lib.so
@@ -2582,6 +2585,12 @@ uninstall-am:
25822585 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--gc-sections gc_tls_test.o
25832586 @GCC_TRUE@@NATIVE_LINKER_TRUE@gc_tls_test.stdout: gc_tls_test
25842587 @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
25852594 @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc
25862595 @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $<
25872596 @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld
--- /dev/null
+++ b/gold/testsuite/gc_orphan_section_test.cc
@@ -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+
--- /dev/null
+++ b/gold/testsuite/gc_orphan_section_test.sh
@@ -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
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -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.
18
29 For older changes see ChangeLog-2009
310
--- /dev/null
+++ b/ld/testsuite/ld-gc/abi-note.d
@@ -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+#...
--- /dev/null
+++ b/ld/testsuite/ld-gc/abi-note.s
@@ -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 */
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -1,5 +1,5 @@
11 # Expect script for ld-gc tests
2-# Copyright 2008, 2009
2+# Copyright 2008, 2009, 2010
33 # Free Software Foundation, Inc.
44 #
55 # 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"
9090 test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
9191
9292 run_dump_test "noent"
93+run_dump_test "abi-note"
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -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+
19 2010-01-06 Quentin Neill <quentin.neill@amd.com>
210
311 * i386-gen.c (cpu_flag_init): Add new CPU_AMDFAM15_FLAGS.
--- a/opcodes/cgen-ibld.in
+++ b/opcodes/cgen-ibld.in
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/fr30-ibld.c
+++ b/opcodes/fr30-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/frv-ibld.c
+++ b/opcodes/frv-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/ip2k-ibld.c
+++ b/opcodes/ip2k-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/iq2000-ibld.c
+++ b/opcodes/iq2000-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/lm32-ibld.c
+++ b/opcodes/lm32-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/m32c-ibld.c
+++ b/opcodes/m32c-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/m32r-ibld.c
+++ b/opcodes/m32r-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/mep-ibld.c
+++ b/opcodes/mep-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/mt-ibld.c
+++ b/opcodes/mt-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/openrisc-ibld.c
+++ b/opcodes/openrisc-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/xc16x-ibld.c
+++ b/opcodes/xc16x-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/opcodes/xstormy16-ibld.c
+++ b/opcodes/xstormy16-ibld.c
@@ -138,7 +138,7 @@ insert_normal (CGEN_CPU_DESC cd,
138138 if (length == 0)
139139 return NULL;
140140
141- if (word_length > 32)
141+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
142142 abort ();
143143
144144 /* For architectures with insns smaller than the base-insn-bitsize,
@@ -442,7 +442,7 @@ extract_normal (CGEN_CPU_DESC cd,
442442 return 1;
443443 }
444444
445- if (word_length > 32)
445+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
446446 abort ();
447447
448448 /* For architectures with insns smaller than the insn-base-bitsize,
@@ -469,7 +469,7 @@ extract_normal (CGEN_CPU_DESC cd,
469469 {
470470 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8;
471471
472- if (word_length > 32)
472+ if (word_length > 8 * sizeof (CGEN_INSN_INT))
473473 abort ();
474474
475475 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0)
--- a/winsup/doc/ChangeLog
+++ b/winsup/doc/ChangeLog
@@ -1,3 +1,7 @@
1+2010-01-07 Corinna Vinschen <corinna@vinschen.de>
2+
3+ * overview.sgml: Fix Red Hat brand name.
4+
15 2010-01-04 Christopher Faylor <me+cygwin@cgf.cx>
26
37 * overview.sgml: Fix Red Hat URL.
--- a/winsup/doc/overview.sgml
+++ b/winsup/doc/overview.sgml
@@ -48,7 +48,7 @@ library, you may want the Cygwin proprietary-use license.
4848 For more information about the proprietary-use license, please go to
4949 <ulink url="http://www.redhat.com/services/custom/cygwin/">http://www.redhat.com/services/custom/cygwin/</ulink>.
5050 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
5252 questions should be sent to the project mailing list
5353 <email>cygwin@cygwin.com</email>.</para>
5454
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -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+
113 2009-12-17 Christopher Faylor <me+cygwin@cgf.cx>
214
315 * ps.cc (main): Return 0 if pid found.
--- a/winsup/utils/cygpath.cc
+++ b/winsup/utils/cygpath.cc
@@ -1,6 +1,6 @@
11 /* cygpath.cc -- convert pathnames between Windows and Unix format
22 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.
44
55 This file is part of Cygwin.
66
@@ -16,7 +16,6 @@ details. */
1616 #include <wchar.h>
1717 #include <locale.h>
1818 #include <stdlib.h>
19-#include <argz.h>
2019 #include <limits.h>
2120 #include <getopt.h>
2221 #include <windows.h>
@@ -30,7 +29,7 @@ details. */
3029 #include <ddk/ntifs.h>
3130 #include "wide_path.h"
3231
33-static const char version[] = "$Revision$";
32+static const char version[] = "$Revision: 1.58 $";
3433
3534 static char *prog_name;
3635 static char *file_arg, *output_arg;
@@ -227,6 +226,7 @@ get_device_name (char *path)
227226 a valid DOS device name, if prepended with "\\.\". Return that
228227 valid DOS path. */
229228 ULONG len = RtlUnicodeStringToAnsiSize (&odi->ObjectName);
229+ free (ret);
230230 ret = (char *) malloc (len + 4);
231231 strcpy (ret, "\\\\.\\");
232232 ans.Length = 0;
@@ -667,10 +667,18 @@ do_sysfolders (char option)
667667 }
668668 else
669669 {
670+ char *tmp;
671+
670672 if (shortname_flag)
671- buf = get_short_name (buf);
673+ {
674+ buf = get_short_name (tmp = buf);
675+ free (tmp);
676+ }
672677 if (mixed_flag)
673- buf = get_mixed_name (buf);
678+ {
679+ buf = get_mixed_name (tmp = buf);
680+ free (tmp);
681+ }
674682 }
675683 printf ("%s\n", buf);
676684 }
@@ -696,8 +704,8 @@ report_mode (char *filename)
696704 static void
697705 do_pathconv (char *filename)
698706 {
699- char *buf;
700- wchar_t *buf2;
707+ char *buf = NULL, *tmp;
708+ wchar_t *buf2 = NULL;
701709 DWORD len;
702710 ssize_t err;
703711 cygwin_conv_path_t conv_func =
@@ -738,13 +746,23 @@ do_pathconv (char *filename)
738746 {
739747 if (err)
740748 /* oops */;
741- buf = get_device_paths (buf);
749+ buf = get_device_paths (tmp = buf);
750+ free (tmp);
742751 if (shortname_flag)
743- buf = get_short_paths (buf);
752+ {
753+ buf = get_short_paths (tmp = buf);
754+ free (tmp);
755+ }
744756 if (longname_flag)
745- buf = get_long_paths (buf);
757+ {
758+ buf = get_long_paths (tmp = buf);
759+ free (tmp);
760+ }
746761 if (mixed_flag)
747- buf = get_mixed_name (buf);
762+ {
763+ buf = get_mixed_name (tmp = buf);
764+ free (tmp);
765+ }
748766 }
749767 if (err)
750768 {
@@ -766,11 +784,21 @@ do_pathconv (char *filename)
766784 if (!unix_flag)
767785 {
768786 my_wcstombs (buf, buf2, 32768);
769- buf = get_device_name (buf);
787+ buf = get_device_name (tmp = buf);
788+ free (tmp);
770789 if (shortname_flag)
771- buf = get_short_name (buf);
790+ {
791+ buf = get_short_name (tmp = buf);
792+ free (tmp);
793+ }
772794 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;
774802 if (strncmp (buf, "\\\\?\\", 4) == 0)
775803 {
776804 len = 4;
@@ -784,11 +812,18 @@ do_pathconv (char *filename)
784812 }
785813 }
786814 if (mixed_flag)
787- buf = get_mixed_name (buf);
815+ {
816+ buf = get_mixed_name (buf);
817+ free (tmp);
818+ }
788819 }
789820 }
790821
791822 puts (buf);
823+ if (buf2)
824+ free (buf2);
825+ if (buf)
826+ free (buf);
792827 }
793828
794829 static void
@@ -1029,10 +1064,7 @@ main (int argc, char **argv)
10291064 {
10301065 int o;
10311066
1032- /* Use locale from environment. If not set or set to "C", use UTF-8. */
10331067 setlocale (LC_CTYPE, "");
1034- if (!strcmp (setlocale (LC_CTYPE, NULL), "C"))
1035- setlocale (LC_CTYPE, "en_US.UTF-8");
10361068 prog_name = strrchr (argv[0], '/');
10371069 if (!prog_name)
10381070 prog_name = strrchr (argv[0], '\\');
@@ -1070,35 +1102,33 @@ main (int argc, char **argv)
10701102
10711103 while (fgets (buf, sizeof (buf), fp))
10721104 {
1073- size_t azl = 0;
1074- int ac;
1075- char *az, **av;
1105+ int ac = 0;
1106+ char *av[4] = { NULL, NULL, NULL, NULL };
10761107 char *p = strchr (buf, '\n');
10771108 if (p)
10781109 *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 == '-')
10801114 {
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);
10831125 }
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
10891127 {
1090- perror ("cygpath");
1091- exit (1);
1128+ output_flag = 0;
1129+ optind = 1;
10921130 }
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;
10991131 action (ac, av, o);
1100- free (az);
1101- free (av);
11021132 }
11031133 }
11041134 exit (0);
Show on old repository browser