-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/dwarf: support compressed debug sections #11773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What does "go version" output? Alex |
What operating system? Can you show us the output of "go build -x" for a small failing program? |
go version is "go1.5beta2 linux/amd64" go build -x test.go (the program above):
|
Thanks. Next step: copy test.go into an empty directory, cd to that directory, and run CGO_LDFLAGS="-g -O2" go tool cgo -debug-gcc -objdir . -importpath command-line-arguments -- -I . test.go Please attach the output of that. Also, do you have GOROOT set in the environment? |
I have GOROOT set, but I also tried to unset it and ran the program, either way it gives me an error
|
You should never set GOROOT in the environment, but I understand that you are saying that this is not the problem here. Please put this (from the end of the above) into a file x.c: #line 3 "/home/qeed/t/test.go" #include <stddef.h> /* for ptrdiff_t and size_t below */ /* Define intgo when compiling with GCC. */ typedef struct { char *p; intgo n; } GoString; Then run gcc -w -Wno-error -o./cgo.o -gdwarf-2 -c -xc -I . -m64 x.c Then attach the output of readelf -s --wide ./cgo.o Thanks. |
I should also say that 1.5beta1 used to work, so there was a commit between then and now that broke it Symbol table '.symtab' contains 15 entries: |
My apologies, I wrote the wrong thing. I was looking for readelf -S --wide ./_cgo.o (upper case -S, not lower case -s). It's extremely odd that this changed between beta1 and beta2. I can not see any relevant changes in cmd/cgo, cmd/go, debug/elf, debug/dwarf, and I can't think of any other relevant code. |
Hm, I have tried reverting back to 1.4.2 and now it gives me the same error, maybe there is something wrong with my gcc install, though I can't think of anything I did recently that could affect it. I tried with CC=clang and it works for me. I might have to reinstall some packages, but in the mean time let me paste the readelf output
|
Thanks. Your compiler is emitting compressed debug info. The Go packages don't know how to parse that yet. This is done by the assembler, via the --compress-debug-sections option. Something must have changed to cause that to happen by default. |
/cc @aclements |
@ianlancetaylor, is there a reference for compressed DWARF? The best I was able to find is a few sentences at https://sourceware.org/gdb/wiki/Internals%20Debugging-File-Formats (which may be sufficient). I presume the relocations must apply to the decompressed sections, even though the section table technically says they apply to the compressed sections? In that case, I think we have to do this in debug/elf before passing the sections to debug/dwarf, simply because debug/elf handles the relocations. |
That link is the old way. The new way is the SHF_COMPRESSED flag in an ELF section. Search for SHF_COMPRESSED in http://www.sco.com/developers/gabi/latest/ch4.sheader.html . As you say, relocation offsets apply to the uncompressed data. |
CL https://golang.org/cl/17340 mentions this issue. |
Okay. Is there a flag to ask gcc 4.8.4/as 2.24/ld 2.24 (gold 1.11?) to generate compressed sections so I can test my implementation? Or do I need a newer toolchain? |
Looks like you need a newer toolchain. In fact, it looks like you need 2.26, which doesn't exist yet. I can send you an object if you like. |
Oh. :)
Please do. Both ELF32 and ELF64 if that's possible. |
Sent by direct e-mail. |
CL https://golang.org/cl/17341 mentions this issue. |
GCC and LLVM support zlib-compressing DWARF debug sections (and there's some evidence that this may be happening by default in some circumstances now). Add support for reading compressed DWARF sections. Since ELF relocations apply to the decompressed data, decompression is done before applying relocations. Since relcations are applied by debug/elf, decompression must also be handled there. Note that this is different from compressed ELF sections, which is a more general mechanism used by very recent versions of GCC. Updates #11773. Change-Id: I3f4bf1b04d0802cc1e8fcb7c2a5fcf6c467c5089 Reviewed-on: https://go-review.googlesource.com/17340 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Russ Cox <[email protected]>
I upgraded to go 1.5 beta2 and get this error when building any cgo libraries
cannot load DWARF output from $WORK/command-line-arguments/_obj//cgo.o: decoding dwarf section info at offset 0x0: too short
even simple programs that just does
fails to build for me
Using gcc 4.9.2 on amd64
The text was updated successfully, but these errors were encountered: