/* objcopy.c -- copy object file from input to output, optionally massaging it.
- Copyright (C) 1991-2015 Free Software Foundation, Inc.
+ Copyright (C) 1991-2016 Free Software Foundation, Inc.
This file is part of GNU Binutils.
decompress = 1 << 4
} do_debug_sections = nothing;
+/* Whether to generate ELF common symbols with the STT_COMMON type. */
+static enum bfd_link_discard do_elf_stt_common = unchanged;
+
/* Whether to change the leading character in symbol names. */
static bfd_boolean change_leading_char = FALSE;
OPTION_DEBUGGING,
OPTION_DECOMPRESS_DEBUG_SECTIONS,
OPTION_DUMP_SECTION,
+ OPTION_ELF_STT_COMMON,
OPTION_EXTRACT_DWO,
OPTION_EXTRACT_SYMBOL,
OPTION_FILE_ALIGNMENT,
{"discard-all", no_argument, 0, 'x'},
{"discard-locals", no_argument, 0, 'X'},
{"dump-section", required_argument, 0, OPTION_DUMP_SECTION},
+ {"elf-stt-common", required_argument, 0, OPTION_ELF_STT_COMMON},
{"enable-deterministic-archives", no_argument, 0, 'D'},
{"extract-dwo", no_argument, 0, OPTION_EXTRACT_DWO},
{"extract-symbol", no_argument, 0, OPTION_EXTRACT_SYMBOL},
--compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\
Compress DWARF debug sections using zlib\n\
--decompress-debug-sections Decompress DWARF debug sections using zlib\n\
+ --elf-stt-common=[yes|no] Generate ELF common symbols with STT_COMMON\n\
+ type\n\
-v --verbose List all object files modified\n\
@<file> Read options from <file>\n\
-V --version Display this program's version number\n\
#define PARSE_OTHER(fname,fval) \
else if (len >= (int) sizeof fname && strncasecmp (fname, s, sizeof fname - 1) == 0) \
- fval = strndup (s + sizeof fname - 1, len - sizeof fname + 1)
+ fval = xstrndup (s + sizeof fname - 1, len - sizeof fname + 1)
if (0) ;
PARSE_FLAG ("local", BSF_LOCAL);
return FALSE;
}
- if ((do_debug_sections & compress) != 0
- && do_debug_sections != compress
- && ibfd->xvec->flavour != bfd_target_elf_flavour)
+ if (ibfd->xvec->flavour != bfd_target_elf_flavour)
{
- non_fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported on `%s'"),
- bfd_get_archive_filename (ibfd));
- return FALSE;
+ if ((do_debug_sections & compress) != 0
+ && do_debug_sections != compress)
+ {
+ non_fatal (_("--compress-debug-sections=[zlib|zlib-gnu|zlib-gabi] is unsupported on `%s'"),
+ bfd_get_archive_filename (ibfd));
+ return FALSE;
+ }
+
+ if (do_elf_stt_common)
+ {
+ non_fatal (_("--elf-stt-common=[yes|no] is unsupported on `%s'"),
+ bfd_get_archive_filename (ibfd));
+ return FALSE;
+ }
}
if (verbose)
break;
}
+ switch (do_elf_stt_common)
+ {
+ case elf_stt_common:
+ ibfd->flags |= BFD_CONVERT_ELF_COMMON | BFD_USE_ELF_STT_COMMON;
+ break;
+ break;
+ case no_elf_stt_common:
+ ibfd->flags |= BFD_CONVERT_ELF_COMMON;
+ break;
+ default:
+ break;
+ }
+
if (bfd_check_format (ibfd, bfd_archive))
{
bfd_boolean force_output_target;
fatal (_("bad format for %s"), "--add-symbol");
t = strchr (s + 1, ':');
- newsym->symdef = strndup (optarg, s - optarg);
+ newsym->symdef = xstrndup (optarg, s - optarg);
if (t)
{
- newsym->section = strndup (s + 1, t - (s + 1));
+ newsym->section = xstrndup (s + 1, t - (s + 1));
newsym->symval = strtol (t + 1, NULL, 0);
}
else
do_debug_sections = decompress;
break;
+ case OPTION_ELF_STT_COMMON:
+ if (strcasecmp (optarg, "yes") == 0)
+ do_elf_stt_common = elf_stt_common;
+ else if (strcasecmp (optarg, "no") == 0)
+ do_elf_stt_common = no_elf_stt_common;
+ else
+ fatal (_("unrecognized --elf-stt-common= option `%s'"),
+ optarg);
+ break;
+
case OPTION_GAP_FILL:
{
bfd_vma gap_fill_vma;