Re: RFC: Add support for SHF_COMPRESSED

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.gnu.binutils,gmane.comp.gdb.devel
Message-ID <CAMe9rOqR4tgNr9CvZXoGsO4ASxZyaAp47J4DL=VNtC9AuLYKGA@mail.gmail.com>
On Fri, Mar 13, 2015 at 9:19 AM, Jan Beulich <[email protected]> wrote:
>>>> On 13.03.15 at 17:13, <[email protected]> wrote:
>> On Fri, Mar 13, 2015 at 9:05 AM, Jan Beulich <[email protected]> wrote:
>>>>>> On 13.03.15 at 16:31, <[email protected]> wrote:
>>>> I am working on SHF_COMPRESSED support:
>>>>
>>>> http://www.sco.com/developers/gabi/latest/ch4.sheader.html
>>>>
>>>> We already have .zdebug* sections, which aren't compatible
>>>> with SHF_COMPRESSED scheme due to missing compression
>>>> header.   What section names should we use for SHF_COMPRESSED
>>>> debug sections.  Using .debug* or .zdebug*  will break existing tools.
>>>> I am thinking .zlibdebug*  or ..Zdebug*.  Any suggestions?
>>>
>>> Why would they need to have different names anyway? They're
>>> distinguishable by the flag.
>>
>> Won't the exiting tools, like GDB, choke on compressed .debug* sections?
>
> If they're well behaved, they shouldn't (they should just ignore
> them).
>

I implemented SHF_COMPRESSED on users/hjl/compressed
branch. The old gdb doesn't understand SHF_COMPRESSED:

Reading symbols from bfd.gz...Dwarf Error: wrong version in
compilation unit header (is 136, should be 2, 3, or 4) [in module
/export/home/hjl/bugs/binutils/compressed-2/bfd.gz]
(no debugging symbols found)...done.
(gdb)

and the new gdb works fine:

Reading symbols from gold.gz...done.
(gdb) b main
Breakpoint 1 at 0x400450: file x.c, line 6.
(gdb) r
Starting program: /export/home/hjl/bugs/binutils/compressed-2/gold.gz

Breakpoint 1, main () at x.c:6
6  printf ("hello world\n");
(gdb)

I added --compressed-debug-sections=[none|zlib] to as and
objcopy.  I updated gold to decompress SHF_COMPRESSED
section.  I didn't add --compressed-debug-sections=[none|zlib]
to gold since I don't know if this name is a final choice nor
gold maintainers want such an option.

I wrote some as/objcopy tests:

[hjl@gnu-6 compressed-1]$ make
./as --x32 --nocompress-debug-sections -o x.o x.s
./as --x32 --compressed-debug-sections=zlib -o compressed0.o x.s
./objcopy --compressed-debug-sections=zlib x.o compressed.o
cmp compressed.o compressed0.o
./as --x32 --compress-debug-sections -o compress0.o x.s
./objcopy --compress-debug-sections x.o compress.o
cmp compress.o compress0.o
./objcopy --compressed-debug-sections=none x.o decompressed.o
cmp x.o decompressed.o
./objcopy --compressed-debug-sections=none compressed.o decompressed.o
cmp compressed.o decompressed.o
./objcopy --compressed-debug-sections=none compress.o decompressed.o
cmp compress.o decompressed.o
./objcopy --decompress-debug-sections compressed.o decompressed.o
cmp x.o decompressed.o
./objcopy --decompress-debug-sections compress.o decompressed.o
cmp x.o decompressed.o
cp x.o y.o
ar rv libx.a y.o
ar: creating libx.a
a - y.o
ar rc libx.a y.o
./objcopy --compressed-debug-sections=zlib x.o compressed1.o
cmp compressed1.o compressed.o
./objcopy --compressed-debug-sections=zlib compress.o compressed2.o
cmp compressed2.o compressed.o
./objcopy --compress-debug-sections compressed.o compresse1.o
cmp compresse1.o compress.o
./objcopy --compressed-debug-sections=zlib libx.a liby.a
ar xv liby.a y.o
x - y.o
cmp y.o compressed.o
./objcopy --compress-debug-sections liby.a
ar xv liby.a y.o
x - y.o
cmp y.o compress.o
./objcopy --compressed-debug-sections=zlib liby.a
ar xv liby.a y.o
x - y.o
cmp y.o compressed.o
./objcopy --decompress-debug-sections liby.a
ar xv liby.a y.o
x - y.o
cmp y.o decompressed.o
[hjl@gnu-6 compressed-1]$

and ld/gold/gdb tests:

gcc -mx32 -B./ -g -Wa,--compressed-debug-sections=zlib -c x.c -o x.o
gcc -mx32 -B./ -o bfd x.o -fuse-ld=bfd
gcc -mx32 -B./ -o gold x.o -fuse-ld=gold
./objcopy --compressed-debug-sections=zlib gold gold.gz
./objcopy --compressed-debug-sections=zlib bfd bfd.gz
./gdb -batch -x gdb.cmd bfd.gz
Breakpoint 1 at 0x4003b0: file x.c, line 6.

Breakpoint 1, main () at x.c:6
6  printf ("hello world\n");
A debugging session is active.

Inferior 1 [process 5951] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
./gdb -batch -x gdb.cmd gold.gz
Breakpoint 1 at 0x400450: file x.c, line 6.

Breakpoint 1, main () at x.c:6
6  printf ("hello world\n");
A debugging session is active.

Inferior 1 [process 5962] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
[hjl@gnu-6 compressed-2]$

Any feedbacks?

Thanks.

-- 
H.J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.