aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-04-08 07:53:54 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-04-08 07:54:09 -0700
commit151411f8af16723a12e0e0eedc1ecdbea648c1b0 (patch)
treec1e9bd46096b7c153f60c144429f6ba52d07fa43 /ld/testsuite
parentbfcf0ccd0131621213c5d6f2908cd703a90176f7 (diff)
downloadgdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.zip
gdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.tar.gz
gdb-151411f8af16723a12e0e0eedc1ecdbea648c1b0.tar.bz2
Add SHF_COMPRESSED support to gas and objcopy
This patch adds --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi} options to gas and objcopy for ELF files. They control how DWARF debug sections are compressed. --compress-debug-sections=none is equivalent to --nocompress-debug-sections. --compress-debug-sections=zlib and --compress-debug-sections=zlib-gnu are equivalent to --compress-debug-sections. --compress-debug-sections=zlib-gabi compresses DWARF debug sections with SHF_COMPRESSED from the ELF ABI. No linker changes are required to support SHF_COMPRESSED. bfd/ * archive.c (_bfd_get_elt_at_filepos): Also copy BFD_COMPRESS_GABI bit. * bfd.c (bfd::flags): Increase size to 18 bits. (BFD_COMPRESS_GABI): New. (BFD_FLAGS_SAVED): Add BFD_COMPRESS_GABI. (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. (bfd_update_compression_header): New fuction. (bfd_check_compression_header): Likewise. (bfd_get_compression_header_size): Likewise. (bfd_is_section_compressed_with_header): Likewise. * compress.c (MAX_COMPRESSION_HEADER_SIZE): New. (bfd_compress_section_contents): Return the uncompressed size if the full section contents is compressed successfully. Support converting from/to .zdebug* sections. (bfd_get_full_section_contents): Call bfd_get_compression_header_size to get compression header size. (bfd_is_section_compressed): Renamed to ... (bfd_is_section_compressed_with_header): This. Add a pointer argument to return compression header size. (bfd_is_section_compressed): Use it. (bfd_init_section_decompress_status): Call bfd_get_compression_header_size to get compression header size. Return FALSE if uncompressed section size is 0. * elf.c (_bfd_elf_make_section_from_shdr): Support converting from/to .zdebug* sections. * bfd-in2.h: Regenerated. binutils/ * objcopy.c (do_debug_sections): Add compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_options): Use optional_argument on compress-debug-sections. (copy_usage): Update --compress-debug-sections. (copy_file): Handle compress_zlib, compress_gnu_zlib and compress_gabi_zlib. (copy_main): Handle --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * doc/binutils.texi: Document --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. binutils/testsuite/ * compress.exp: Add tests for --compress-debug-sections={none|zlib|zlib-gnu|zlib-gabi}. * binutils-all/dw2-3.rS: New file. * binutils-all/dw2-3.rt: Likewise. * binutils-all/libdw2-compressedgabi.out: Likewise. gas/ * 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}. gas/testsuite/ * 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. ld/testsuite/ * ld-elf/compress.exp: Add a test for --compress-debug-sections=zlib-gabi. (build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi. (run_tests): Likewise. Verify linker output with zlib-gabi compressed debug input. * ld-elf/compressed1a.d: New file. * ld-elf/compressed1b.d: Likewise. * ld-elf/compressed1c.d: Likewise.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog11
-rw-r--r--ld/testsuite/ld-elf/compress.exp26
-rw-r--r--ld/testsuite/ld-elf/compressed1a.d10
-rw-r--r--ld/testsuite/ld-elf/compressed1b.d9
-rw-r--r--ld/testsuite/ld-elf/compressed1c.d10
5 files changed, 64 insertions, 2 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index ef54e67..cfa22f4 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2015-04-08 H.J. Lu <hongjiu.lu@intel.com>
+
+ * ld-elf/compress.exp: Add a test for
+ --compress-debug-sections=zlib-gabi.
+ (build_tests): Add 2 tests for --compress-debug-sections=zlib-gabi.
+ (run_tests): Likewise.
+ Verify linker output with zlib-gabi compressed debug input.
+ * ld-elf/compressed1a.d: New file.
+ * ld-elf/compressed1b.d: Likewise.
+ * ld-elf/compressed1c.d: Likewise.
+
2015-04-07 Alan Modra <amodra@gmail.com>
* ld-arm/tls-gdesc-nlazy.g: Adjust for readelf note.
diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp
index 682811a..adb7fc2 100644
--- a/ld/testsuite/ld-elf/compress.exp
+++ b/ld/testsuite/ld-elf/compress.exp
@@ -40,6 +40,10 @@ if { ![ld_assemble $as "--compress-debug-sections $srcdir/$subdir/empty.s" tmpdi
fail "linker compressed debug sections"
}
+if { ![ld_assemble $as "--compress-debug-sections=zlib-gabi $srcdir/$subdir/empty.s" tmpdir/emptyzlib.o ] } {
+ fail "linker compressed debug sections"
+}
+
set build_tests {
{"Build libfoo.so with compressed debug sections"
"-shared" "-fPIC -g -Wa,--compress-debug-sections"
@@ -47,13 +51,31 @@ set build_tests {
{"Build libbar.so with compressed debug sections"
"-shared" "-fPIC -g -Wa,--compress-debug-sections"
{begin.c end.c} {} "libbar.so"}
+ {"Build libfoozlib.so with compressed debug sections with zlib-gabi"
+ "-shared" "-fPIC -g -Wa,--compress-debug-sections=zlib-gabi"
+ {foo.c} {} "libfoozlib.so"}
+ {"Build libbarzlib.so with compressed debug sections with zlib-gabi"
+ "-shared" "-fPIC -g -Wa,--compress-debug-sections=zlib-gabi"
+ {begin.c end.c} {} "libbarzlib.so"}
}
set run_tests {
{"Run normal with libfoo.so with compressed debug sections"
- "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "-Wa,--compress-debug-sections"
- {main.c} "normal" "normal.out"}
+ "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
+ {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections"}
+ {"Run normal with libfoo.so with compressed debug sections with zlib-gabi"
+ "tmpdir/begin.o tmpdir/libfoozlib.so tmpdir/end.o" ""
+ {main.c} "normal" "normal.out" "-Wa,--compress-debug-sections=zlib-gabi"}
}
run_cc_link_tests $build_tests
run_ld_link_exec_tests [] $run_tests
+
+set test_name "Link with zlib-gabi compressed debug input"
+send_log "cmp tmpdir/libfoo.so tmpdir/libfoozlib.so\n"
+if { [catch {exec cmp tmpdir/libfoo.so tmpdir/libfoozlib.so}] } then {
+ send_log "tmpdir/libfoo.so tmpdir/libfoozlib.so differ.\n"
+ fail "$test_name"
+} else {
+ pass "$test_name"
+}
diff --git a/ld/testsuite/ld-elf/compressed1a.d b/ld/testsuite/ld-elf/compressed1a.d
new file mode 100644
index 0000000..653c203
--- /dev/null
+++ b/ld/testsuite/ld-elf/compressed1a.d
@@ -0,0 +1,10 @@
+#source: compress1.s
+#as: --compress-debug-sections=zlib-gabi
+#ld: -e func_cu2
+#readelf: -t
+#notarget: alpha-*
+
+#failif
+#...
+ .*COMPRESSED.*
+#...
diff --git a/ld/testsuite/ld-elf/compressed1b.d b/ld/testsuite/ld-elf/compressed1b.d
new file mode 100644
index 0000000..83dc60f
--- /dev/null
+++ b/ld/testsuite/ld-elf/compressed1b.d
@@ -0,0 +1,9 @@
+#source: compress1.s
+#as: --compress-debug-sections=zlib-gabi
+#ld: -r
+#readelf: -t
+
+#failif
+#...
+ .*COMPRESSED.*
+#...
diff --git a/ld/testsuite/ld-elf/compressed1c.d b/ld/testsuite/ld-elf/compressed1c.d
new file mode 100644
index 0000000..64f75be
--- /dev/null
+++ b/ld/testsuite/ld-elf/compressed1c.d
@@ -0,0 +1,10 @@
+#source: compress1.s
+#as: --compress-debug-sections=zlib-gabi
+#ld: -shared
+#readelf: -t
+#target: *-*-linux* *-*-gnu*
+
+#failif
+#...
+ .*COMPRESSED.*
+#...