diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-13 12:41:24 -0700 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2014-06-13 12:41:24 -0700 |
commit | bcfb04363768d7eb2910bbefb263effae28ace10 (patch) | |
tree | ae6a83c097abff3d8925159b3c1d50138059f556 | |
parent | 54f1b3cf509cd889905287cb8ce6c5ae33911a21 (diff) | |
download | toolchain_binutils-bcfb04363768d7eb2910bbefb263effae28ace10.zip toolchain_binutils-bcfb04363768d7eb2910bbefb263effae28ace10.tar.gz toolchain_binutils-bcfb04363768d7eb2910bbefb263effae28ace10.tar.bz2 |
[2.25] apply local patches
7a17fb955bb42018c3c84e003700ac120c3502d4
b2a417bdb17191ef2afc20bbd308e308c0730403
e0bca373a85fa71b89d9ea42370433b3c0499b9d
57fbbfbda5a77b558c24a44e7eed8c4030c31bcd
160ce55a90bcdcb3000d74805795969edc3f8422
b33d0ddc123435be5e60ebb15a37b3bfb651dc7e
f25603579c0a04b3d5099259cf54c5b3c8775b78
1000fadfaa979b623e1fbd0c87858be4f5b6dffd
83cabeb81083ac53719eaaf68c48734ff9c48fa9
Change-Id: I174be6632426ed720e643bca7c48a9077b31d34b
-rw-r--r-- | binutils-2.25/bfd/elf-attrs.c | 6 | ||||
-rw-r--r-- | binutils-2.25/bfd/elf-bfd.h | 5 | ||||
-rw-r--r-- | binutils-2.25/bfd/elf32-arm.c | 19 | ||||
-rw-r--r-- | binutils-2.25/gas/config/tc-arm.c | 7 | ||||
-rw-r--r-- | binutils-2.25/gold/object.cc | 44 | ||||
-rw-r--r-- | binutils-2.25/include/ansidecl.h | 141 | ||||
-rw-r--r-- | binutils-2.25/ld/emulparams/elf32bmip.sh | 8 | ||||
-rw-r--r-- | binutils-2.25/ld/emulparams/elf32ltsmip.sh | 1 | ||||
-rwxr-xr-x | binutils-2.25/ld/genscripts.sh | 5 | ||||
-rw-r--r-- | binutils-2.25/ld/scripttempl/elf.sc | 61 | ||||
-rw-r--r-- | binutils-2.25/libiberty/pex-win32.c | 47 |
11 files changed, 275 insertions, 69 deletions
diff --git a/binutils-2.25/bfd/elf-attrs.c b/binutils-2.25/bfd/elf-attrs.c index 9a6ff6f..1a1c2c2 100644 --- a/binutils-2.25/bfd/elf-attrs.c +++ b/binutils-2.25/bfd/elf-attrs.c @@ -297,7 +297,7 @@ bfd_elf_add_obj_attr_int (bfd *abfd, int vendor, int tag, unsigned int i) obj_attribute *attr; attr = elf_new_obj_attr (abfd, vendor, tag); - attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag); + attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag) | ATTR_TYPE_FLAG_EXIST; attr->i = i; } @@ -320,7 +320,7 @@ bfd_elf_add_obj_attr_string (bfd *abfd, int vendor, int tag, const char *s) obj_attribute *attr; attr = elf_new_obj_attr (abfd, vendor, tag); - attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag); + attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag) | ATTR_TYPE_FLAG_EXIST; attr->s = _bfd_elf_attr_strdup (abfd, s); } @@ -332,7 +332,7 @@ bfd_elf_add_obj_attr_int_string (bfd *abfd, int vendor, int tag, obj_attribute *attr; attr = elf_new_obj_attr (abfd, vendor, tag); - attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag); + attr->type = _bfd_elf_obj_attrs_arg_type (abfd, vendor, tag) | ATTR_TYPE_FLAG_EXIST; attr->i = i; attr->s = _bfd_elf_attr_strdup (abfd, s); } diff --git a/binutils-2.25/bfd/elf-bfd.h b/binutils-2.25/bfd/elf-bfd.h index add80b3..6af1624 100644 --- a/binutils-2.25/bfd/elf-bfd.h +++ b/binutils-2.25/bfd/elf-bfd.h @@ -1450,17 +1450,20 @@ struct bfd_elf_section_data /* The value of an object attribute. The type indicates whether the attribute holds and integer, a string, or both. It can also indicate that there can - be no default (i.e. all values must be written to file, even zero). */ + be no default (i.e. all values must be written to file, even zero), and whether + it exists in bfd to begin with. */ typedef struct obj_attribute { #define ATTR_TYPE_FLAG_INT_VAL (1 << 0) #define ATTR_TYPE_FLAG_STR_VAL (1 << 1) #define ATTR_TYPE_FLAG_NO_DEFAULT (1 << 2) +#define ATTR_TYPE_FLAG_EXIST (1 << 3) #define ATTR_TYPE_HAS_INT_VAL(TYPE) ((TYPE) & ATTR_TYPE_FLAG_INT_VAL) #define ATTR_TYPE_HAS_STR_VAL(TYPE) ((TYPE) & ATTR_TYPE_FLAG_STR_VAL) #define ATTR_TYPE_HAS_NO_DEFAULT(TYPE) ((TYPE) & ATTR_TYPE_FLAG_NO_DEFAULT) +#define ATTR_TYPE_EXIST(TYPE) ((TYPE) & ATTR_TYPE_FLAG_EXIST) int type; unsigned int i; diff --git a/binutils-2.25/bfd/elf32-arm.c b/binutils-2.25/bfd/elf32-arm.c index 5af1643..197af59 100644 --- a/binutils-2.25/bfd/elf32-arm.c +++ b/binutils-2.25/bfd/elf32-arm.c @@ -11804,7 +11804,9 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) nothing. */ else if (in_attr[i].i == 0) { - BFD_ASSERT (in_attr[Tag_ABI_HardFP_use].i == 0); + /* When linking against earlier version of object file, Tag_FP_arch may not + even exist, while Tag_ABI_HardFP_use is non-zero. */ + BFD_ASSERT (!ATTR_TYPE_EXIST(in_attr[i].type) || in_attr[Tag_ABI_HardFP_use].i == 0); break; } @@ -15814,6 +15816,21 @@ const struct elf_size_info elf32_arm_size_info = #define elf_backend_obj_attrs_order elf32_arm_obj_attrs_order #define elf_backend_obj_attrs_handle_unknown elf32_arm_obj_attrs_handle_unknown +#undef elf_backend_plt_sym_val +#define elf_backend_plt_sym_val elf32_arm_plt_sym_val + +/* Return address for Ith PLT stub in section PLT, for relocation REL + or (bfd_vma) -1 if it should not be included. */ + +static bfd_vma +elf32_arm_plt_sym_val (bfd_vma i, const asection *plt, + const arelent *rel ATTRIBUTE_UNUSED) +{ + return plt->vma + 4 * ( + ARRAY_SIZE(elf32_arm_plt0_entry) + + ARRAY_SIZE(elf32_arm_plt_entry) * i); +} + #include "elf32-target.h" /* Native Client targets. */ diff --git a/binutils-2.25/gas/config/tc-arm.c b/binutils-2.25/gas/config/tc-arm.c index f97c307..d170f43 100644 --- a/binutils-2.25/gas/config/tc-arm.c +++ b/binutils-2.25/gas/config/tc-arm.c @@ -11130,9 +11130,16 @@ do_t_mov_cmp (void) results. Don't allow this. */ if (low_regs) { +/* Silence this error for now because clang generates "MOV" two low regs in + unified syntax for thumb1, and expects CPSR are not affected. This check + doesn't exist in binutils-2.21 with gcc 4.6. The thumb1 code generated by + clang will continue to have problem running on v5t but not on v6 and beyond. +*/ +#if 0 constraint (!ARM_CPU_HAS_FEATURE (cpu_variant, arm_ext_v6), "MOV Rd, Rs with two low registers is not " "permitted on this architecture"); +#endif ARM_MERGE_FEATURE_SETS (thumb_arch_used, thumb_arch_used, arm_ext_v6); } diff --git a/binutils-2.25/gold/object.cc b/binutils-2.25/gold/object.cc index c98b3c5..b1feacc 100644 --- a/binutils-2.25/gold/object.cc +++ b/binutils-2.25/gold/object.cc @@ -1704,6 +1704,28 @@ Sized_relobj_file<size, big_endian>::do_layout(Symbol_table* symtab, if (!is_pass_two) layout->layout_gnu_stack(seen_gnu_stack, gnu_stack_flags, this); + // Handle the .eh_frame sections after the other sections. + gold_assert(!is_pass_one || eh_frame_sections.empty()); + for (std::vector<unsigned int>::const_iterator p = eh_frame_sections.begin(); + p != eh_frame_sections.end(); + ++p) + { + unsigned int i = *p; + const unsigned char* pshdr; + pshdr = section_headers_data + i * This::shdr_size; + typename This::Shdr shdr(pshdr); + + this->layout_eh_frame_section(layout, + symbols_data, + symbols_size, + symbol_names_data, + symbol_names_size, + i, + shdr, + reloc_shndx[i], + reloc_type[i]); + } + // When doing a relocatable link handle the reloc sections at the // end. Garbage collection and Identical Code Folding is not // turned on for relocatable code. @@ -1756,28 +1778,6 @@ Sized_relobj_file<size, big_endian>::do_layout(Symbol_table* symtab, out_section_offsets[i] = invalid_address; } - // Handle the .eh_frame sections at the end. - gold_assert(!is_pass_one || eh_frame_sections.empty()); - for (std::vector<unsigned int>::const_iterator p = eh_frame_sections.begin(); - p != eh_frame_sections.end(); - ++p) - { - unsigned int i = *p; - const unsigned char* pshdr; - pshdr = section_headers_data + i * This::shdr_size; - typename This::Shdr shdr(pshdr); - - this->layout_eh_frame_section(layout, - symbols_data, - symbols_size, - symbol_names_data, - symbol_names_size, - i, - shdr, - reloc_shndx[i], - reloc_type[i]); - } - // When building a .gdb_index section, scan the .debug_info and // .debug_types sections. gold_assert(!is_pass_one diff --git a/binutils-2.25/include/ansidecl.h b/binutils-2.25/include/ansidecl.h index 0fb23bb..5cd03a7 100644 --- a/binutils-2.25/include/ansidecl.h +++ b/binutils-2.25/include/ansidecl.h @@ -1,6 +1,6 @@ /* ANSI and traditional C compatability macros Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2013 + 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -24,16 +24,93 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. Macro ANSI C definition Traditional C definition ----- ---- - ---------- ----------- - ---------- + ANSI_PROTOTYPES 1 not defined PTR `void *' `char *' + PTRCONST `void *const' `char *' + LONG_DOUBLE `long double' `double' const not defined `' volatile not defined `' signed not defined `' + VA_START(ap, var) va_start(ap, var) va_start(ap) + + Note that it is safe to write "void foo();" indicating a function + with no return value, in all K+R compilers we have been able to test. + + For declaring functions with prototypes, we also provide these: + + PARAMS ((prototype)) + -- for functions which take a fixed number of arguments. Use this + when declaring the function. When defining the function, write a + K+R style argument list. For example: + + char *strcpy PARAMS ((char *dest, char *source)); + ... + char * + strcpy (dest, source) + char *dest; + char *source; + { ... } + + + VPARAMS ((prototype, ...)) + -- for functions which take a variable number of arguments. Use + PARAMS to declare the function, VPARAMS to define it. For example: + + int printf PARAMS ((const char *format, ...)); + ... + int + printf VPARAMS ((const char *format, ...)) + { + ... + } + + For writing functions which take variable numbers of arguments, we + also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros. These + hide the differences between K+R <varargs.h> and C89 <stdarg.h> more + thoroughly than the simple VA_START() macro mentioned above. + + VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end. + Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls + corresponding to the list of fixed arguments. Then use va_arg + normally to get the variable arguments, or pass your va_list object + around. You do not declare the va_list yourself; VA_OPEN does it + for you. + + Here is a complete example: + + int + printf VPARAMS ((const char *format, ...)) + { + int result; + + VA_OPEN (ap, format); + VA_FIXEDARG (ap, const char *, format); + + result = vfprintf (stdout, format, ap); + VA_CLOSE (ap); + + return result; + } + + + You can declare variables either before or after the VA_OPEN, + VA_FIXEDARG sequence. Also, VA_OPEN and VA_CLOSE are the beginning + and end of a block. They must appear at the same nesting level, + and any variables declared after VA_OPEN go out of scope at + VA_CLOSE. Unfortunately, with a K+R compiler, that includes the + argument list. You can have multiple instances of VA_OPEN/VA_CLOSE + pairs in a single function in case you need to traverse the + argument list more than once. For ease of writing code which uses GCC extensions but needs to be portable to other compilers, we provide the GCC_VERSION macro that simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various wrappers around __attribute__. Also, __extension__ will be #defined - to nothing if it doesn't work. See below. */ + to nothing if it doesn't work. See below. + + This header also defines a lot of obsolete macros: + CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID, + AND, DOTS, NOARGS. Don't use them. */ #ifndef _ANSIDECL_H #define _ANSIDECL_H 1 @@ -72,8 +149,28 @@ So instead we use the macro below and test it against specific values. */ C++ compilers, does not define __STDC__, though it acts as if this was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */ +#define ANSI_PROTOTYPES 1 #define PTR void * +#define PTRCONST void *const +#define LONG_DOUBLE long double +/* PARAMS is often defined elsewhere (e.g. by libintl.h), so wrap it in + a #ifndef. */ +#ifndef PARAMS +#define PARAMS(ARGS) ARGS +#endif + +#define VPARAMS(ARGS) ARGS +#define VA_START(VA_LIST, VAR) va_start(VA_LIST, VAR) + +/* variadic function helper macros */ +/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's + use without inhibiting further decls and without declaring an + actual variable. */ +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP, VAR); { struct Qdmy +#define VA_CLOSE(AP) } va_end(AP); } +#define VA_FIXEDARG(AP, T, N) struct Qdmy + #undef const #undef volatile #undef signed @@ -91,9 +188,35 @@ So instead we use the macro below and test it against specific values. */ # endif #endif +/* These are obsolete. Do not use. */ +#ifndef IN_GCC +#define CONST const +#define VOLATILE volatile +#define SIGNED signed + +#define PROTO(type, name, arglist) type name arglist +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(void) +#define AND , +#define DOTS , ... +#define NOARGS void +#endif /* ! IN_GCC */ + #else /* Not ANSI C. */ +#undef ANSI_PROTOTYPES #define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define PARAMS(args) () +#define VPARAMS(args) (va_alist) va_dcl +#define VA_START(va_list, var) va_start(va_list) + +#define VA_OPEN(AP, VAR) { va_list AP; va_start(AP); { struct Qdmy +#define VA_CLOSE(AP) } va_end(AP); } +#define VA_FIXEDARG(AP, TYPE, NAME) TYPE NAME = va_arg(AP, TYPE) /* some systems define these in header files for non-ansi mode */ #undef const @@ -105,6 +228,20 @@ So instead we use the macro below and test it against specific values. */ #define signed #define inline +#ifndef IN_GCC +#define CONST +#define VOLATILE +#define SIGNED + +#define PROTO(type, name, arglist) type name () +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() +#define AND ; +#define DOTS +#define NOARGS +#endif /* ! IN_GCC */ + #endif /* ANSI C. */ /* Define macros for some gcc attributes. This permits us to use the diff --git a/binutils-2.25/ld/emulparams/elf32bmip.sh b/binutils-2.25/ld/emulparams/elf32bmip.sh index 118d57a..2289685 100644 --- a/binutils-2.25/ld/emulparams/elf32bmip.sh +++ b/binutils-2.25/ld/emulparams/elf32bmip.sh @@ -6,7 +6,7 @@ SCRIPT_NAME=elf OUTPUT_FORMAT="elf32-bigmips" BIG_OUTPUT_FORMAT="elf32-bigmips" LITTLE_OUTPUT_FORMAT="elf32-littlemips" -TEXT_START_ADDR=0x0400000 +TEXT_START_ADDR=0x80000 test -n "${EMBEDDED}" || DATA_ADDR=0x10000000 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" @@ -64,12 +64,6 @@ OTHER_BSS_SYMBOLS='_fbss = .;' OTHER_SECTIONS=' .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } - .mdebug.abi32 0 : { KEEP(*(.mdebug.abi32)) } - .mdebug.abiN32 0 : { KEEP(*(.mdebug.abiN32)) } - .mdebug.abi64 0 : { KEEP(*(.mdebug.abi64)) } - .mdebug.abiO64 0 : { KEEP(*(.mdebug.abiO64)) } - .mdebug.eabi32 0 : { KEEP(*(.mdebug.eabi32)) } - .mdebug.eabi64 0 : { KEEP(*(.mdebug.eabi64)) } .gcc_compiled_long32 0 : { KEEP(*(.gcc_compiled_long32)) } .gcc_compiled_long64 0 : { KEEP(*(.gcc_compiled_long64)) } ' diff --git a/binutils-2.25/ld/emulparams/elf32ltsmip.sh b/binutils-2.25/ld/emulparams/elf32ltsmip.sh index 4a660f0..edf73df 100644 --- a/binutils-2.25/ld/emulparams/elf32ltsmip.sh +++ b/binutils-2.25/ld/emulparams/elf32ltsmip.sh @@ -1,2 +1,3 @@ . ${srcdir}/emulparams/elf32btsmip.sh OUTPUT_FORMAT="elf32-tradlittlemips" +unset TEXT_DYNAMIC diff --git a/binutils-2.25/ld/genscripts.sh b/binutils-2.25/ld/genscripts.sh index a4da92d..f9e7d4e 100755 --- a/binutils-2.25/ld/genscripts.sh +++ b/binutils-2.25/ld/genscripts.sh @@ -224,7 +224,8 @@ case :${lib_path1}:${lib_path2}: in *) LIB_PATH=${lib_path1}:${lib_path2} ;; esac -LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` +# For Android, comment out LIB_SEARCH_DIRS. +#LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` # We need it for testsuite. set $EMULATION_LIBPATH @@ -290,6 +291,7 @@ LD_FLAG= DATA_ALIGNMENT=${DATA_ALIGNMENT_} RELOCATING=" " ( echo "/* Default linker script, for normal executables */" + echo "/* Modified for Android. */" . ${CUSTOMIZER_SCRIPT} . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.x @@ -343,6 +345,7 @@ if test -n "$GENERATE_SHLIB_SCRIPT"; then DATA_ALIGNMENT=${DATA_ALIGNMENT_sc-${DATA_ALIGNMENT}} COMBRELOC=ldscripts/${EMULATION_NAME}.xsc.tmp ( echo "/* Script for --shared -z combreloc: shared library, combine & sort relocs */" + echo "/* Modified for Android. */" . ${CUSTOMIZER_SCRIPT} . ${srcdir}/scripttempl/${SCRIPT_NAME}.sc ) | sed -e '/^ *$/d;s/[ ]*$//' > ldscripts/${EMULATION_NAME}.xsc diff --git a/binutils-2.25/ld/scripttempl/elf.sc b/binutils-2.25/ld/scripttempl/elf.sc index e8126cb..b1e6906 100644 --- a/binutils-2.25/ld/scripttempl/elf.sc +++ b/binutils-2.25/ld/scripttempl/elf.sc @@ -122,7 +122,12 @@ DATA_SEGMENT_ALIGN="ALIGN(${SEGMENT_SIZE}) + (. & (${MAXPAGESIZE} - 1))" DATA_SEGMENT_RELRO_END="" DATA_SEGMENT_END="" if test -n "${COMMONPAGESIZE}"; then - DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + if [ "$ELFSIZE" = "64" ]; then + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}) - ((${MAXPAGESIZE} - .) & (${MAXPAGESIZE} - 1)); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + else + # For 32, we align at exactly a page boundary. + DATA_SEGMENT_ALIGN="ALIGN (${SEGMENT_SIZE}); . = DATA_SEGMENT_ALIGN (${MAXPAGESIZE}, ${COMMONPAGESIZE})" + fi DATA_SEGMENT_END=". = DATA_SEGMENT_END (.);" DATA_SEGMENT_RELRO_END=". = DATA_SEGMENT_RELRO_END (${SEPARATE_GOTPLT-0}, .);" fi @@ -160,7 +165,7 @@ RELA_IPLT=".rela.iplt ${RELOCATING-0} : DYNAMIC=".dynamic ${RELOCATING-0} : { *(.dynamic) }" RODATA=".${RODATA_NAME} ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }" DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }" -DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }" +DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.mdebug.*) }" if test -z "${NO_SMALL_DATA}"; then SBSS=".${SBSS_NAME} ${RELOCATING-0} : { @@ -235,8 +240,8 @@ test "${LARGE_SECTIONS}" = "yes" && LARGE_SECTIONS=" if test "${ENABLE_INITFINI_ARRAY}" = "yes"; then SORT_INIT_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))" SORT_FINI_ARRAY="KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))" - CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors" - DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors" + CTORS_IN_INIT_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors" + DTORS_IN_FINI_ARRAY="EXCLUDE_FILE (*crtbegin.o *crtbegin*.o *crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors" else SORT_INIT_ARRAY="KEEP (*(SORT(.init_array.*)))" SORT_FINI_ARRAY="KEEP (*(SORT(.fini_array.*)))" @@ -245,17 +250,15 @@ else fi INIT_ARRAY=".init_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} + KEEP (*crtbegin*.o(.init_array)) ${SORT_INIT_ARRAY} KEEP (*(.init_array ${CTORS_IN_INIT_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} }" FINI_ARRAY=".fini_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} + KEEP (*crtbegin*.o(.fini_array)) ${SORT_FINI_ARRAY} KEEP (*(.fini_array ${DTORS_IN_FINI_ARRAY})) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} }" CTOR=".ctors ${CONSTRUCTING-0} : { @@ -271,14 +274,14 @@ CTOR=".ctors ${CONSTRUCTING-0} : is in. */ KEEP (*crtbegin.o(.ctors)) - KEEP (*crtbegin?.o(.ctors)) + KEEP (*crtbegin*.o(.ctors)) /* We don't want to include the .ctor section from the crtend.o file until after the sorted ctors. The .ctor section from the crtend file contains the end of ctors marker and it must be last */ - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .ctors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) ${CONSTRUCTING+${CTOR_END}} @@ -287,8 +290,8 @@ DTOR=".dtors ${CONSTRUCTING-0} : { ${CONSTRUCTING+${DTOR_START}} KEEP (*crtbegin.o(.dtors)) - KEEP (*crtbegin?.o(.dtors)) - KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o $OTHER_EXCLUDE_FILES) .dtors)) + KEEP (*crtbegin*.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend*.o $OTHER_EXCLUDE_FILES) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) ${CONSTRUCTING+${DTOR_END}} @@ -299,8 +302,11 @@ STACK=" .stack ${RELOCATING-0}${RELOCATING+${STACK_ADDR}} : *(.stack) }" -TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" -SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +# For Android, remove SEGMENT_START. +#TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${TEXT_START_ADDR})" +#SHLIB_TEXT_START_ADDR="SEGMENT_START(\"text-segment\", ${SHLIB_TEXT_START_ADDR:-0})" +TEXT_START_ADDR="${TEXT_START_ADDR}" +SHLIB_TEXT_START_ADDR="0" if [ -z "$SEPARATE_CODE" ]; then SIZEOF_HEADERS_CODE=" + SIZEOF_HEADERS" @@ -531,8 +537,8 @@ cat <<EOF .exception_ranges*) } ${TEXT_PLT+${PLT_NEXT_DATA+${PLT}}} - /* Adjust the address for the data segment. We want to adjust up to - the same address within the page on the next page up. */ + /* Adjust the address for the data segment. For 32 bits we want to align + at exactly a page boundary to make life easier for apriori. */ ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} @@ -546,14 +552,23 @@ cat <<EOF .tdata ${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) } .tbss ${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} } + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} .preinit_array ${RELOCATING-0} : { - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}} KEEP (*(.preinit_array)) - ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} } + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}} ${RELOCATING+${INIT_ARRAY}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}} ${RELOCATING+${FINI_ARRAY}} + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}} ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } @@ -601,10 +616,8 @@ cat <<EOF *(COMMON) /* Align here to ensure that the .bss section occupies space up to _end. Align after .bss to ensure correct alignment even if the - .bss section disappears because there are no input sections. - FIXME: Why do we need it? When there is no .bss section, we don't - pad the .data section. */ - ${RELOCATING+. = ALIGN(. != 0 ? ${ALIGNMENT} : 1);} + .bss section disappears because there are no input sections. */ + ${RELOCATING+. = ALIGN(${ALIGNMENT});} } ${OTHER_BSS_SECTIONS} ${LARGE_BSS_AFTER_BSS+${LARGE_BSS}} @@ -623,7 +636,9 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A ${LARGE_BSS_AFTER_BSS-${LARGE_BSS}} ${RELOCATING+. = ALIGN(${ALIGNMENT});} ${RELOCATING+${OTHER_END_SYMBOLS}} - ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}} + ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; + _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; + PROVIDE (${USER_LABEL_PREFIX}end = .);}} ${RELOCATING+${DATA_SEGMENT_END}} EOF diff --git a/binutils-2.25/libiberty/pex-win32.c b/binutils-2.25/libiberty/pex-win32.c index eae72c5..bd99584 100644 --- a/binutils-2.25/libiberty/pex-win32.c +++ b/binutils-2.25/libiberty/pex-win32.c @@ -340,17 +340,26 @@ argv_to_cmdline (char *const *argv) char *p; size_t cmdline_len; int i, j, k; + int needs_quotes; cmdline_len = 0; for (i = 0; argv[i]; i++) { - /* We quote every last argument. This simplifies the problem; - we need only escape embedded double-quotes and immediately + /* We only quote arguments that contain spaces, \n \t \v or " characters + to prevent wasting 2 chars per argument of the CreateProcess 32k char limit + We need only escape embedded double-quotes and immediately preceeding backslash characters. A sequence of backslach characters that is not follwed by a double quote character will not be escaped. */ + needs_quotes = 0; for (j = 0; argv[i][j]; j++) { + if (argv[i][j] == ' ' || argv[i][j] == '\n' || + argv[i][j] == '\t' || argv[i][j] == '"' ) + { + needs_quotes = 1; + } + if (argv[i][j] == '"') { /* Escape preceeding backslashes. */ @@ -362,16 +371,33 @@ argv_to_cmdline (char *const *argv) } /* Trailing backslashes also need to be escaped because they will be followed by the terminating quote. */ - for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--) - cmdline_len++; + if (needs_quotes) + { + for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--) + cmdline_len++; + } cmdline_len += j; - cmdline_len += 3; /* for leading and trailing quotes and space */ + cmdline_len += 1 + (needs_quotes<<1); /* for leading and trailing quotes and space */ } cmdline = XNEWVEC (char, cmdline_len); p = cmdline; for (i = 0; argv[i]; i++) { - *p++ = '"'; + needs_quotes = 0; + for (j = 0; argv[i][j]; j++) + { + if (argv[i][j] == ' ' || argv[i][j] == '\n' || + argv[i][j] == '\t' || argv[i][j] == '"' ) + { + needs_quotes = 1; + break; + } + } + + if (needs_quotes) + { + *p++ = '"'; + } for (j = 0; argv[i][j]; j++) { if (argv[i][j] == '"') @@ -382,9 +408,12 @@ argv_to_cmdline (char *const *argv) } *p++ = argv[i][j]; } - for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--) - *p++ = '\\'; - *p++ = '"'; + if (needs_quotes) + { + for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--) + *p++ = '\\'; + *p++ = '"'; + } *p++ = ' '; } p[-1] = '\0'; |