* [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str.
@ 2017-03-03 9:59 Mark Wielaard
2017-03-05 12:16 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Mark Wielaard @ 2017-03-03 9:59 UTC (permalink / raw)
To: binutils; +Cc: Mark Wielaard
Putting the name, comp_dir and producer strings in the .debug_str section
makes it possible to share them across CUs. This saves a small amount of
space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes
it easier for tools like rpm debugedit to adjust the source paths when
generating separate debuginfo files.
gas/
* dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of
DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer.
(out_debug_info): Accept symbols to name, comp_dir and producer in
the .debug_str section and emit those offsets not full strings.
(out_debug_str): New function that outputs the strings for name,
comp_dir and producer in .debug_str and generates symbols to those
strings.
(out_debug_line): Create a .debug_str section if necessary and call
out_debug_str before calling out_debug_info.
---
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 4bb658b..e02b6e8 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -1726,9 +1726,9 @@ out_debug_abbrev (segT abbrev_seg,
else
out_abbrev (DW_AT_ranges, DW_FORM_data8);
}
- out_abbrev (DW_AT_name, DW_FORM_string);
- out_abbrev (DW_AT_comp_dir, DW_FORM_string);
- out_abbrev (DW_AT_producer, DW_FORM_string);
+ out_abbrev (DW_AT_name, DW_FORM_strp);
+ out_abbrev (DW_AT_comp_dir, DW_FORM_strp);
+ out_abbrev (DW_AT_producer, DW_FORM_strp);
out_abbrev (DW_AT_language, DW_FORM_data2);
out_abbrev (0, 0);
@@ -1739,15 +1739,11 @@ out_debug_abbrev (segT abbrev_seg,
/* Emit a description of this compilation unit for .debug_info. */
static void
-out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
+out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg,
+ symbolS *name_sym, symbolS *comp_dir_sym, symbolS *producer_sym)
{
- char producer[128];
- const char *comp_dir;
- const char *dirname;
expressionS exp;
symbolS *info_end;
- char *p;
- int len;
int sizeof_offset;
sizeof_offset = out_header (info_seg, &exp);
@@ -1798,10 +1794,38 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset);
}
+ /* DW_AT_name, DW_AT_comp_dir and DW_AT_producer. Symbols in .debug_str
+ setup in out_debug_str below. */
+ TC_DWARF2_EMIT_OFFSET (name_sym, sizeof_offset);
+ TC_DWARF2_EMIT_OFFSET (comp_dir_sym, sizeof_offset);
+ TC_DWARF2_EMIT_OFFSET (producer_sym, sizeof_offset);
+
+ /* DW_AT_language. Yes, this is probably not really MIPS, but the
+ dwarf2 draft has no standard code for assembler. */
+ out_two (DW_LANG_Mips_Assembler);
+
+ symbol_set_value_now (info_end);
+}
+
+/* Emit the three debug strings needed in .debug_str and setup symbols
+ to them for use in out_debug_info. */
+static void
+out_debug_str (segT str_seg, symbolS **name_sym, symbolS **comp_dir_sym,
+ symbolS **producer_sym)
+{
+ char producer[128];
+ const char *comp_dir;
+ const char *dirname;
+ char *p;
+ int len;
+
+ subseg_set (str_seg, 0);
+
/* DW_AT_name. We don't have the actual file name that was present
on the command line, so assume files[1] is the main input file.
We're not supposed to get called unless at least one line number
entry was emitted, so this should always be defined. */
+ *name_sym = symbol_temp_new_now ();
if (files_in_use == 0)
abort ();
if (files[1].dir)
@@ -1823,22 +1847,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg)
memcpy (p, files[1].filename, len);
/* DW_AT_comp_dir */
+ *comp_dir_sym = symbol_temp_new_now ();
comp_dir = remap_debug_filename (getpwd ());
len = strlen (comp_dir) + 1;
p = frag_more (len);
memcpy (p, comp_dir, len);
/* DW_AT_producer */
+ *producer_sym = symbol_temp_new_now ();
sprintf (producer, "GNU AS %s", VERSION);
len = strlen (producer) + 1;
p = frag_more (len);
memcpy (p, producer, len);
-
- /* DW_AT_language. Yes, this is probably not really MIPS, but the
- dwarf2 draft has no standard code for assembler. */
- out_two (DW_LANG_Mips_Assembler);
-
- symbol_set_value_now (info_end);
}
void
@@ -1907,19 +1927,22 @@ dwarf2_finish (void)
out_debug_line (line_seg);
/* If this is assembler generated line info, and there is no
- debug_info already, we need .debug_info and .debug_abbrev
- sections as well. */
+ debug_info already, we need .debug_info, .debug_abbrev and
+ .debug_str sections as well. */
if (emit_other_sections)
{
segT abbrev_seg;
segT aranges_seg;
segT ranges_seg;
+ segT str_seg;
+ symbolS *name_sym, *comp_dir_sym, *producer_sym;
gas_assert (all_segs);
info_seg = subseg_new (".debug_info", 0);
abbrev_seg = subseg_new (".debug_abbrev", 0);
aranges_seg = subseg_new (".debug_aranges", 0);
+ str_seg = subseg_new (".debug_str", 0);
bfd_set_section_flags (stdoutput, info_seg,
SEC_READONLY | SEC_DEBUGGING);
@@ -1927,6 +1950,10 @@ dwarf2_finish (void)
SEC_READONLY | SEC_DEBUGGING);
bfd_set_section_flags (stdoutput, aranges_seg,
SEC_READONLY | SEC_DEBUGGING);
+ bfd_set_section_flags (stdoutput, str_seg,
+ (SEC_READONLY | SEC_DEBUGGING
+ | SEC_MERGE | SEC_STRINGS));
+ str_seg->entsize = 1;
record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1);
@@ -1943,6 +1970,8 @@ dwarf2_finish (void)
out_debug_aranges (aranges_seg, info_seg);
out_debug_abbrev (abbrev_seg, info_seg, line_seg);
- out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg);
+ out_debug_str (str_seg, &name_sym, &comp_dir_sym, &producer_sym);
+ out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg,
+ name_sym, comp_dir_sym, producer_sym);
}
}
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str.
2017-03-03 9:59 [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str Mark Wielaard
@ 2017-03-05 12:16 ` Alan Modra
2017-03-05 21:57 ` Mark Wielaard
0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2017-03-05 12:16 UTC (permalink / raw)
To: Mark Wielaard; +Cc: binutils
On Fri, Mar 03, 2017 at 10:59:27AM +0100, Mark Wielaard wrote:
> Putting the name, comp_dir and producer strings in the .debug_str section
> makes it possible to share them across CUs. This saves a small amount of
> space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes
> it easier for tools like rpm debugedit to adjust the source paths when
> generating separate debuginfo files.
>
> gas/
> * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of
> DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer.
> (out_debug_info): Accept symbols to name, comp_dir and producer in
> the .debug_str section and emit those offsets not full strings.
> (out_debug_str): New function that outputs the strings for name,
> comp_dir and producer in .debug_str and generates symbols to those
> strings.
> (out_debug_line): Create a .debug_str section if necessary and call
> out_debug_str before calling out_debug_info.
OK, but please adjust gas/testsuite/gas/aarch64/dwarf.d for this
change.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str.
2017-03-05 12:16 ` Alan Modra
@ 2017-03-05 21:57 ` Mark Wielaard
2017-03-06 0:15 ` Alan Modra
0 siblings, 1 reply; 4+ messages in thread
From: Mark Wielaard @ 2017-03-05 21:57 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 678 bytes --]
On Sun, Mar 05, 2017 at 10:46:23PM +1030, Alan Modra wrote:
> OK, but please adjust gas/testsuite/gas/aarch64/dwarf.d for this
> change.
Thanks, I added the extra section symbol to that testcase as attached.
But this shows I failed to properly run all testcases for gas.
I had assumed running configure --enable-targets=all from the top-level
binutils-gdb would enable all targets/checks for gas. But I see now that
all non-native targets/checks were build/run. I could check this change
with configure --target=aarch64-pc-linux-gnu. But what is the correct
way to configure/build/check binutils-gdb for such a change to gas to
get all gas target tests to run?
Thanks,
Mark
[-- Attachment #2: gas-gdwarf-aarch64-extra-section-sym.patch --]
[-- Type: text/plain, Size: 1061 bytes --]
diff --git a/gas/testsuite/gas/aarch64/dwarf.d b/gas/testsuite/gas/aarch64/dwarf.d
index 005f1d5..2a75e0b 100644
--- a/gas/testsuite/gas/aarch64/dwarf.d
+++ b/gas/testsuite/gas/aarch64/dwarf.d
@@ -1,7 +1,7 @@
#readelf: -s --debug-dump=aranges
#as: -g
-Symbol table '.symtab' contains 10 entries:
+Symbol table '.symtab' contains 11 entries:
Num:[ ]+Value[ ]+Size[ ]+Type[ ]+Bind[ ]+Vis[ ]+Ndx[ ]+Name
0: 0+ 0 NOTYPE LOCAL DEFAULT UND[ ]+
1: 0+ 0 SECTION LOCAL DEFAULT 1[ ]+
@@ -11,8 +11,9 @@ Symbol table '.symtab' contains 10 entries:
5: 0+ 0 SECTION LOCAL DEFAULT 6[ ]+
6: 0+ 0 SECTION LOCAL DEFAULT 8[ ]+
7: 0+ 0 SECTION LOCAL DEFAULT 4[ ]+
- 8: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+
- 9: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc
+ 8: 0+ 0 SECTION LOCAL DEFAULT 11[ ]+
+ 9: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+
+ 10: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc
Contents of the .debug_aranges section:
Length: (44|28)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str.
2017-03-05 21:57 ` Mark Wielaard
@ 2017-03-06 0:15 ` Alan Modra
0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2017-03-06 0:15 UTC (permalink / raw)
To: Mark Wielaard; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]
On Sun, Mar 05, 2017 at 10:57:41PM +0100, Mark Wielaard wrote:
> On Sun, Mar 05, 2017 at 10:46:23PM +1030, Alan Modra wrote:
> > OK, but please adjust gas/testsuite/gas/aarch64/dwarf.d for this
> > change.
>
> Thanks, I added the extra section symbol to that testcase as attached.
>
> But this shows I failed to properly run all testcases for gas.
> I had assumed running configure --enable-targets=all from the top-level
> binutils-gdb would enable all targets/checks for gas. But I see now that
> all non-native targets/checks were build/run. I could check this change
> with configure --target=aarch64-pc-linux-gnu. But what is the correct
> way to configure/build/check binutils-gdb for such a change to gas to
> get all gas target tests to run?
Unfortunately, we don't have a canned official test procedure. I
still use a bash script I hacked together a long time ago.
There's also this:
https://sourceware.org/ml/binutils/2017-02/msg00135.html
--
Alan Modra
Australia Development Lab, IBM
[-- Attachment #2: dotest --]
[-- Type: text/plain, Size: 1803 bytes --]
let i=0
test -e gastest_pass && mv -f gastest_pass gastest_lastpass
for z in `cat targets`
do
( test -d $z || mkdir $z
cd $z;
echo "~/src/binutils-gdb/configure --build=x86_64-linux --disable-nls --enable-plugins --disable-gdb --disable-sim --disable-readline --disable-libdecnumber --enable-obsolete --target=$z" > zzz.$$
chmod 755 zzz.$$
xx=29
for x in 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
do
test -f make.log$x && mv -f make.log$x make.log$xx
test -f check.log$x && mv -f check.log$x check.log$xx
xx=$x
done
if test x$1 = xfull || ! test -f zzz || ! cmp -s zzz zzz.$$; then
rm -rf bfd binutils etc gas gprof intl ld libiberty opcodes Makefile config.log config.status serdep.tmp gdb sim readline libdecnumber cgen zlib
mv -f zzz.$$ zzz
./zzz &> make.log0
else
rm zzz.$$
./zzz &> make.log0
fi
if make &>> make.log0; then
( eval cd `sed -n -e '/\/configure/{s,/configure .*,,p;q}' <zzz` && git show -s --oneline FETCH_HEAD ) &> check.log0
if make -k check &>> check.log0; then
echo "$z OK"
echo "$z OK" >> ../gastest_pass
else
echo "$z check"
fi
else
echo "$z ********make"
fi
cd ..
) &
let i++
#Don't let m68hc11-elf and m68hc12-elf write to the source at the same time.
if test $i = 16 -o $z = m68hc11-elf; then
let i=0
wait
fi
done
if test $i != 0; then
wait
fi
egrep -a '(XPASS|FAIL|ERROR|UNRESOLVED):' */check.log0 | sed -e s,/check.log0:,\ \ , > gastest_results
sort < gastest_pass > gastest_$$ && mv -f gastest_$$ gastest_pass
diff -u gastest_lastpass gastest_pass &> gastest_changes
for z in */check.log1; do diff -u $z ${z%[0-9]}0 | sed -e s,^,${z%/*}\ \ ,; done | egrep -a ' [\+\-](XPASS|FAIL|ERROR|UNRESOLVED)' >> gastest_changes
[-- Attachment #3: targets --]
[-- Type: text/plain, Size: 1703 bytes --]
aarch64-linux alpha-dec-vms alpha-linux alpha-linuxecoff alpha-netbsd alpha-unknown-freebsd4.7 am33_2.0-linux arc-linux-uclibc arm-aout arm-coff arm-epoc-pe arm-linuxeabi arm-nacl arm-netbsdelf arm-nto arm-pe arm-symbianelf arm-vxworks arm-wince-pe avr-elf bfin-elf cr16-elf cris-elf crisv32-linux crx-elf d10v-elf d30v-elf dlx-elf epiphany-elf fr30-elf frv-elf frv-linux ft32-elf h8300-elf hppa-linux hppa-hp-hpux10 hppa64-hp-hpux11.23 hppa64-linux i370-linux i386-darwin i386-lynxos i386-netware i386-linuxaout i586-aout i586-coff i586-linux i686-nacl i686-pc-beos i686-pc-elf i686-pe i686-vxworks i860-stardent-elf i960-elf ia64-elf ia64-freebsd5 ia64-hpux ia64-linux ia64-netbsd ia64-vms ip2k-elf iq2000-elf lm32-elf m32c-elf m32r-elf m68hc11-elf m68hc12-elf m68k-elf m68k-linux m68k-netbsd mcore-elf mcore-pe mep-elf metag-linux microblaze-elf mips-ecoff mips-linux mips-vxworks mips64-linux mipsel-linux-gnu mipsisa32el-linux mipstx39-elf mmix mn10200-elf mn10300-elf moxie-elf ms1-elf msp430-elf mt-elf nds32le-elf nios2-linux ns32k-netbsd or1k-elf pdp11-dec-aout pj-elf powerpc-eabisim powerpc-eabivle powerpc-linux powerpc-nto powerpc-wrs-vxworks powerpc64-linux powerpcle-cygwin powerpcle-elf powerpc64le-linux ppc-lynxos pru-elf riscv32-elf riscv64-elf rl78-elf rs6000-aix4.3.3 rs6000-aix5.1 rx-elf s390-linux s390x-linux score-elf sh-linux sh-nto sh-pe sh-rtems sh-vxworks shl-unknown-netbsdelf sparc-aout sparc-coff sparc-linux sparc-vxworks sparc64-linux spu-elf tic30-unknown-aout tic30-unknown-coff tic4x-coff tic54x-coff tic6x-elf tilegx-linux tilepro-linux v850-elf vax-netbsdelf visium-elf x86_64-linux x86_64-mingw32 x86_64-nacl xgate-elf xstormy16-elf xtensa-elf z8k-coff z80-coff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-06 0:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 9:59 [PATCH] gas: Emit name, comp_dir and producer strings in .debug_str Mark Wielaard
2017-03-05 12:16 ` Alan Modra
2017-03-05 21:57 ` Mark Wielaard
2017-03-06 0:15 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).