aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog18
-rw-r--r--gas/as.c28
-rw-r--r--gas/as.h14
-rw-r--r--gas/config/tc-i386.c3
-rw-r--r--gas/doc/as.texinfo16
-rw-r--r--gas/testsuite/ChangeLog9
-rw-r--r--gas/testsuite/gas/i386/dw2-compressed-1.d105
-rw-r--r--gas/testsuite/gas/i386/dw2-compressed-2.d7
-rw-r--r--gas/testsuite/gas/i386/dw2-compressed-3.d104
-rw-r--r--gas/testsuite/gas/i386/i386.exp4
-rw-r--r--gas/testsuite/gas/i386/x86-64-dw2-compressed-2.d7
-rw-r--r--gas/write.c43
12 files changed, 338 insertions, 20 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6f9118da..7ff56c1 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,21 @@
+2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * as.c (show_usage): Update --compress-debug-sections.
+ (std_longopts): Use optional_argument on compress-debug-sections.
+ (parse_args): Handle
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+ * as.h (compressed_debug_section_type): New.
+ (flag_compress_debug): Change type to compressed_debug_section_type.
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+ * write.c (compress_debug): Set BFD_COMPRESS_GABI for
+ --compress-debug-sections=zlib-gabi. Call
+ bfd_get_compression_header_size to get compression header size.
+ Don't rename section name for --compress-debug-sections=zlib-gabi.
+ * config/tc-i386.c (compressed_debug_section_type): Set to
+ COMPRESS_DEBUG_ZLIB.
+ * doc/as.texinfo: Document
+ --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}.
+
2015-04-07 Renlin Li <renlin.li@arm.com>
* config/tc-aarch64.c (mapping_state): Use subseg_text_p.
diff --git a/gas/as.c b/gas/as.c
index a670d3e..2a8923f 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -246,7 +246,7 @@ Options:\n\
fprintf (stream, _("\
--alternate initially turn on alternate macro syntax\n"));
fprintf (stream, _("\
- --compress-debug-sections\n\
+ --compress-debug-sections[={none|zlib|zlib-gnu|zlib-gabi}]\n\
compress DWARF debug sections using zlib\n"));
fprintf (stream, _("\
--nocompress-debug-sections\n\
@@ -471,7 +471,7 @@ parse_args (int * pargc, char *** pargv)
,{"a", optional_argument, NULL, 'a'}
/* Handle -al=<FILE>. */
,{"al", optional_argument, NULL, OPTION_AL}
- ,{"compress-debug-sections", no_argument, NULL, OPTION_COMPRESS_DEBUG}
+ ,{"compress-debug-sections", optional_argument, NULL, OPTION_COMPRESS_DEBUG}
,{"nocompress-debug-sections", no_argument, NULL, OPTION_NOCOMPRESS_DEBUG}
,{"debug-prefix-map", required_argument, NULL, OPTION_DEBUG_PREFIX_MAP}
,{"defsym", required_argument, NULL, OPTION_DEFSYM}
@@ -655,11 +655,31 @@ This program has absolutely no warranty.\n"));
exit (EXIT_SUCCESS);
case OPTION_COMPRESS_DEBUG:
- flag_compress_debug = 1;
+ if (optarg)
+ {
+#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
+ if (strcasecmp (optarg, "none") == 0)
+ flag_compress_debug = COMPRESS_DEBUG_NONE;
+ else if (strcasecmp (optarg, "zlib") == 0)
+ flag_compress_debug = COMPRESS_DEBUG_ZLIB;
+ else if (strcasecmp (optarg, "zlib-gnu") == 0)
+ flag_compress_debug = COMPRESS_DEBUG_GNU_ZLIB;
+ else if (strcasecmp (optarg, "zlib-gabi") == 0)
+ flag_compress_debug = COMPRESS_DEBUG_GABI_ZLIB;
+ else
+ as_fatal (_("Invalid --compress-debug-sections option: `%s'"),
+ optarg);
+#else
+ as_fatal (_("--compress-debug-sections=%s is unsupported"),
+ optarg);
+#endif
+ }
+ else
+ flag_compress_debug = COMPRESS_DEBUG;
break;
case OPTION_NOCOMPRESS_DEBUG:
- flag_compress_debug = 0;
+ flag_compress_debug = COMPRESS_DEBUG_NONE;
break;
case OPTION_DEBUG_PREFIX_MAP:
diff --git a/gas/as.h b/gas/as.h
index 2f05745..e04cc0f 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -370,8 +370,18 @@ COMMON int flag_strip_local_absolute;
/* True if we should generate a traditional format object file. */
COMMON int flag_traditional_format;
-/* TRUE if debug sections should be compressed. */
-COMMON int flag_compress_debug;
+/* Types of compressed debug sections. We currently support zlib. */
+enum compressed_debug_section_type
+{
+ COMPRESS_DEBUG_NONE = 0,
+ COMPRESS_DEBUG,
+ COMPRESS_DEBUG_ZLIB,
+ COMPRESS_DEBUG_GNU_ZLIB,
+ COMPRESS_DEBUG_GABI_ZLIB
+};
+
+/* Type of compressed debug sections we should generate. */
+COMMON enum compressed_debug_section_type flag_compress_debug;
/* TRUE if .note.GNU-stack section with SEC_CODE should be created */
COMMON int flag_execstack;
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 8266134..1ab1252 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -35,7 +35,8 @@
#ifdef TE_LINUX
/* Default to compress debug sections for Linux. */
-int flag_compress_debug = 1;
+enum compressed_debug_section_type flag_compress_debug
+ = COMPRESS_DEBUG_ZLIB;
#endif
#ifndef REGISTER_WARNINGS
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index bedb4d5..95d6c38 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -630,6 +630,22 @@ to begin with @samp{.zdebug}, and the resulting object file may not be
compatible with older linkers and object file utilities. Note if compression
would make a given section @emph{larger} then it is not compressed or renamed.
+@ifset ELF
+@cindex @samp{--compress-debug-sections=} option
+@item --compress-debug-sections=none
+@itemx --compress-debug-sections=zlib
+@itemx --compress-debug-sections=zlib-gnu
+@itemx --compress-debug-sections=zlib-gabi
+These options control how DWARF debug sections are compressed.
+@option{--compress-debug-sections=none} is equivalent to
+@option{--nocompress-debug-sections}.
+@option{--compress-debug-sections=zlib} and
+@option{--compress-debug-sections=zlib-gnu} are equivalent to
+@option{--compress-debug-sections}.
+@option{--compress-debug-sections=zlib-gabi} compresses
+DWARF debug sections with SHF_COMPRESSED from the ELF ABI.
+@end ifset
+
@item --nocompress-debug-sections
Do not compress DWARF debug sections. This is the default.
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index c896ec5..fc2b934 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * gas/i386/dw2-compressed-1.d: New file.
+ * gas/i386/dw2-compressed-2.d: Likewise.
+ * gas/i386/dw2-compressed-3.d: Likewise.
+ * gas/i386/x86-64-dw2-compressed-2.d: Likewise.
+ * gas/i386/i386.exp: Run dw2-compressed-2, dw2-compressed-1,
+ dw2-compressed-3 and x86-64-dw2-compressed-2.
+
2015-04-06 H.J. Lu <hongjiu.lu@intel.com>
* lib/gas-defs.exp (run_dump_test): Remove is_zlib_supported check.
diff --git a/gas/testsuite/gas/i386/dw2-compressed-1.d b/gas/testsuite/gas/i386/dw2-compressed-1.d
new file mode 100644
index 0000000..f4c110d
--- /dev/null
+++ b/gas/testsuite/gas/i386/dw2-compressed-1.d
@@ -0,0 +1,105 @@
+#source: dw2-compress-1.s
+#as: --compress-debug-sections=zlib-gabi
+#readelf: -w
+#name: DWARF2 debugging information 1 with SHF_COMPRESSED
+
+Contents of the .debug_info section:
+
+ Compilation Unit @ offset 0x0:
+ Length: 0x4e \(32-bit\)
+ Version: 2
+ Abbrev Offset: 0x0
+ Pointer Size: 4
+ <0><b>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
+ <c> DW_AT_stmt_list : 0x0
+ <10> DW_AT_high_pc : 0x4
+ <14> DW_AT_low_pc : 0x0
+ <18> DW_AT_name : file1.txt
+ <22> DW_AT_producer : GNU C 3.3.3
+ <2e> DW_AT_language : 1 \(ANSI C\)
+ <1><2f>: Abbrev Number: 2 \(DW_TAG_subprogram\)
+ <30> DW_AT_external : 1
+ <31> DW_AT_decl_file : 1
+ <32> DW_AT_decl_line : 2
+ <33> DW_AT_name : func_cu1
+ <3c> DW_AT_type : <0x4a>
+ <40> DW_AT_low_pc : 0x0
+ <44> DW_AT_high_pc : 0x4
+ <48> DW_AT_frame_base : 1 byte block: 55 \(DW_OP_reg5 \([^()]*\)\)
+ <1><4a>: Abbrev Number: 3 \(DW_TAG_base_type\)
+ <4b> DW_AT_name : int
+ <4f> DW_AT_byte_size : 4
+ <50> DW_AT_encoding : 5 \(signed\)
+ <1><51>: Abbrev Number: 0
+
+Contents of the .debug_abbrev section:
+
+ Number TAG \(0x0\)
+ 1 DW_TAG_compile_unit \[has children\]
+ DW_AT_stmt_list DW_FORM_data4
+ DW_AT_high_pc DW_FORM_addr
+ DW_AT_low_pc DW_FORM_addr
+ DW_AT_name DW_FORM_string
+ DW_AT_producer DW_FORM_string
+ DW_AT_language DW_FORM_data1
+ DW_AT value: 0 DW_FORM value: 0
+ 2 DW_TAG_subprogram \[no children\]
+ DW_AT_external DW_FORM_flag
+ DW_AT_decl_file DW_FORM_data1
+ DW_AT_decl_line DW_FORM_data1
+ DW_AT_name DW_FORM_string
+ DW_AT_type DW_FORM_ref4
+ DW_AT_low_pc DW_FORM_addr
+ DW_AT_high_pc DW_FORM_addr
+ DW_AT_frame_base DW_FORM_block1
+ DW_AT value: 0 DW_FORM value: 0
+ 3 DW_TAG_base_type \[no children\]
+ DW_AT_name DW_FORM_string
+ DW_AT_byte_size DW_FORM_data1
+ DW_AT_encoding DW_FORM_data1
+ DW_AT value: 0 DW_FORM value: 0
+
+Raw dump of debug contents of section .debug_line:
+
+ Offset: 0x0
+ Length: 62
+ DWARF Version: 2
+ Prologue Length: 35
+ Minimum Instruction Length: 1
+ Initial value of 'is_stmt': 1
+ Line Base: 1
+ Line Range: 1
+ Opcode Base: 16
+
+ Opcodes:
+ Opcode 1 has 0 args
+ Opcode 2 has 1 args
+ Opcode 3 has 1 args
+ Opcode 4 has 1 args
+ Opcode 5 has 1 args
+ Opcode 6 has 0 args
+ Opcode 7 has 0 args
+ Opcode 8 has 0 args
+ Opcode 9 has 1 args
+ Opcode 10 has 0 args
+ Opcode 11 has 0 args
+ Opcode 12 has 1 args
+ Opcode 13 has 0 args
+ Opcode 14 has 0 args
+ Opcode 15 has 0 args
+
+ The Directory Table is empty.
+
+ The File Name Table \(offset 0x.*\):
+ Entry Dir Time Size Name
+ 1 0 0 0 file1.txt
+
+ Line Number Statements:
+ \[0x.*\] Extended opcode 2: set Address to 0x0
+ \[0x.*\] Advance Line by 3 to 4
+ \[0x.*\] Copy
+ \[0x.*\] Copy
+ \[0x.*\] Extended opcode 2: set Address to 0x4
+ \[0x.*\] Extended opcode 1: End of Sequence
+
+
diff --git a/gas/testsuite/gas/i386/dw2-compressed-2.d b/gas/testsuite/gas/i386/dw2-compressed-2.d
new file mode 100644
index 0000000..c62c02f
--- /dev/null
+++ b/gas/testsuite/gas/i386/dw2-compressed-2.d
@@ -0,0 +1,7 @@
+#source: dw2-compress-2.s
+#as: --compress-debug-sections=zlib-gabi
+#addr2line: 0x0 0x10 -e
+#name: DWARF2 debugging information 2 with SHF_COMPRESSED
+
+./dw2-compress-2.c:12
+./dw2-compress-2.c:5
diff --git a/gas/testsuite/gas/i386/dw2-compressed-3.d b/gas/testsuite/gas/i386/dw2-compressed-3.d
new file mode 100644
index 0000000..bd2818b
--- /dev/null
+++ b/gas/testsuite/gas/i386/dw2-compressed-3.d
@@ -0,0 +1,104 @@
+#source: dw2-compress-3.s
+#as: --compress-debug-sections=zlib-gabi
+#readelf: -w
+#name: DWARF2 debugging information 3 with SHF_COMPRESSED
+
+Contents of the .debug_info section:
+
+ Compilation Unit @ offset 0x0:
+ Length: 0x32 \(32-bit\)
+ Version: 4
+ Abbrev Offset: 0x0
+ Pointer Size: 4
+ <0><b>: Abbrev Number: 1 \(DW_TAG_compile_unit\)
+ <c> DW_AT_producer : \(indirect string, offset: 0x2\): GNU C 4.8.3
+ <10> DW_AT_language : 1 \(ANSI C\)
+ <11> DW_AT_name : \(indirect string, offset: 0xe\): dw2-compress-3.c
+ <15> DW_AT_comp_dir : \(indirect string, offset: 0x0\): .
+ <19> DW_AT_stmt_list : 0x0
+ <1><1d>: Abbrev Number: 2 \(DW_TAG_variable\)
+ <1e> DW_AT_name : foo
+ <22> DW_AT_decl_file : 1
+ <23> DW_AT_decl_line : 1
+ <24> DW_AT_type : <0x2e>
+ <28> DW_AT_external : 1
+ <28> DW_AT_location : 5 byte block: 3 4 0 0 0 \(DW_OP_addr: 4\)
+ <1><2e>: Abbrev Number: 3 \(DW_TAG_base_type\)
+ <2f> DW_AT_byte_size : 4
+ <30> DW_AT_encoding : 5 \(signed\)
+ <31> DW_AT_name : int
+ <1><35>: Abbrev Number: 0
+
+Contents of the .debug_abbrev section:
+
+ Number TAG \(0x0\)
+ 1 DW_TAG_compile_unit \[has children\]
+ DW_AT_producer DW_FORM_strp
+ DW_AT_language DW_FORM_data1
+ DW_AT_name DW_FORM_strp
+ DW_AT_comp_dir DW_FORM_strp
+ DW_AT_stmt_list DW_FORM_sec_offset
+ DW_AT value: 0 DW_FORM value: 0
+ 2 DW_TAG_variable \[no children\]
+ DW_AT_name DW_FORM_string
+ DW_AT_decl_file DW_FORM_data1
+ DW_AT_decl_line DW_FORM_data1
+ DW_AT_type DW_FORM_ref4
+ DW_AT_external DW_FORM_flag_present
+ DW_AT_location DW_FORM_exprloc
+ DW_AT value: 0 DW_FORM value: 0
+ 3 DW_TAG_base_type \[no children\]
+ DW_AT_byte_size DW_FORM_data1
+ DW_AT_encoding DW_FORM_data1
+ DW_AT_name DW_FORM_string
+ DW_AT value: 0 DW_FORM value: 0
+
+Contents of the .debug_aranges section:
+
+ Length: 20
+ Version: 2
+ Offset into .debug_info: 0x0
+ Pointer Size: 4
+ Segment Size: 0
+
+ Address Length
+ 00000000 00000000
+
+Raw dump of debug contents of section .debug_line:
+
+ Offset: 0x0
+ Length: 45
+ DWARF Version: 2
+ Prologue Length: 39
+ Minimum Instruction Length: 1
+ Initial value of 'is_stmt': 1
+ Line Base: -5
+ Line Range: 14
+ Opcode Base: 13
+
+ Opcodes:
+ Opcode 1 has 0 args
+ Opcode 2 has 1 args
+ Opcode 3 has 1 args
+ Opcode 4 has 1 args
+ Opcode 5 has 1 args
+ Opcode 6 has 0 args
+ Opcode 7 has 0 args
+ Opcode 8 has 0 args
+ Opcode 9 has 1 args
+ Opcode 10 has 0 args
+ Opcode 11 has 0 args
+ Opcode 12 has 1 args
+
+ The Directory Table is empty.
+
+ The File Name Table \(offset 0x1c\):
+ Entry Dir Time Size Name
+ 1 0 0 0 dw2-compress-3.c
+
+ No Line Number Statements.
+Contents of the .debug_str section:
+
+ 0x00000000 2e00474e 55204320 342e382e 33006477 ..GNU C 4.8.3.dw
+ 0x00000010 322d636f 6d707265 73732d33 2e6300 2-compress-3.c.
+
diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
index 92b4424..26cb7ac 100644
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -384,6 +384,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_32_check]]
run_dump_test "debug1"
run_dump_test "dw2-compress-2"
+ run_dump_test "dw2-compressed-2"
run_dump_test "bad-size"
@@ -420,6 +421,8 @@ if [expr [istarget "i*86-*-*"] || [istarget "x86_64-*-*"]] then {
run_list_test_stdin "list-3" "-al"
run_dump_test "dw2-compress-1"
run_dump_test "dw2-compress-3"
+ run_dump_test "dw2-compressed-1"
+ run_dump_test "dw2-compressed-3"
}
}
@@ -735,6 +738,7 @@ if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] t
run_dump_test "x86-64-mpx-branch-2"
run_dump_test "x86-64-dw2-compress-2"
+ run_dump_test "x86-64-dw2-compressed-2"
run_dump_test "x86-64-size-1"
run_dump_test "x86-64-size-2"
diff --git a/gas/testsuite/gas/i386/x86-64-dw2-compressed-2.d b/gas/testsuite/gas/i386/x86-64-dw2-compressed-2.d
new file mode 100644
index 0000000..1200aec
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-dw2-compressed-2.d
@@ -0,0 +1,7 @@
+#source: x86-64-dw2-compress-2.s
+#as: --compress-debug-sections
+#addr2line: 0x0 0x10 -e
+#name: 64bit DWARF2 debugging information 2 with SHF_COMPRESSED
+
+./dw2-compress-2.c:12
+./dw2-compress-2.c:6
diff --git a/gas/write.c b/gas/write.c
index 1ae47a9..bc76962 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1413,6 +1413,9 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
struct z_stream_s *strm;
int x;
flagword flags = bfd_get_section_flags (abfd, sec);
+ unsigned int header_size, compression_header_size;
+ /* Maximimum compression header is 24 bytes. */
+ bfd_byte compression_header[24];
if (seginfo == NULL
|| sec->size < 32
@@ -1427,18 +1430,26 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
if (strm == NULL)
return;
+ if (flag_compress_debug == COMPRESS_DEBUG_GABI_ZLIB)
+ stdoutput->flags |= BFD_COMPRESS | BFD_COMPRESS_GABI;
+ else
+ stdoutput->flags |= BFD_COMPRESS;
+ compression_header_size
+ = bfd_get_compression_header_size (stdoutput, NULL);
+
/* Create a new frag to contain the "ZLIB" header. */
+ header_size = 12 + compression_header_size;
first_newf = frag_alloc (ob);
- if (obstack_room (ob) < 12)
+ if (obstack_room (ob) < header_size)
first_newf = frag_alloc (ob);
- if (obstack_room (ob) < 12)
- as_fatal (_("can't extend frag %u chars"), 12);
+ if (obstack_room (ob) < header_size)
+ as_fatal (_("can't extend frag %u chars"), header_size);
last_newf = first_newf;
- obstack_blank_fast (ob, 12);
+ obstack_blank_fast (ob, header_size);
last_newf->fr_type = rs_fill;
- last_newf->fr_fix = 12;
+ last_newf->fr_fix = header_size;
header = last_newf->fr_literal;
- compressed_size = 12;
+ compressed_size = header_size;
/* Stream the frags through the compression engine, adding new frags
as necessary to accomodate the compressed output. */
@@ -1522,21 +1533,27 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
if (compressed_size >= uncompressed_size)
return;
- memcpy (header, "ZLIB", 4);
- bfd_putb64 (uncompressed_size, header + 4);
+ if (compression_header_size)
+ memcpy (header, compression_header, compression_header_size);
+ memcpy (header + compression_header_size, "ZLIB", 4);
+ bfd_putb64 (uncompressed_size, header + compression_header_size + 4);
/* Replace the uncompressed frag list with the compressed frag list. */
seginfo->frchainP->frch_root = first_newf;
seginfo->frchainP->frch_last = last_newf;
/* Update the section size and its name. */
+ bfd_update_compression_header (abfd, (bfd_byte *) header, sec);
x = bfd_set_section_size (abfd, sec, compressed_size);
gas_assert (x);
- compressed_name = (char *) xmalloc (strlen (section_name) + 2);
- compressed_name[0] = '.';
- compressed_name[1] = 'z';
- strcpy (compressed_name + 2, section_name + 1);
- bfd_section_name (stdoutput, sec) = compressed_name;
+ if (!compression_header_size)
+ {
+ compressed_name = (char *) xmalloc (strlen (section_name) + 2);
+ compressed_name[0] = '.';
+ compressed_name[1] = 'z';
+ strcpy (compressed_name + 2, section_name + 1);
+ bfd_section_name (stdoutput, sec) = compressed_name;
+ }
}
static void