-
Notifications
You must be signed in to change notification settings - Fork 18k
debug/elf: (*Section).Data() returns non-zero data for SHT_NOBITS section #18667
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
I would be inclined to return an error of the That said, I would reconsider if that choice breaks real programs that seem otherwise correct. |
Return an error from both (*Section).Open and (*Section).Data is also fine
with me.
The current behavior of silently returning wrong data (and nil error)
should be fixed.
|
Bumping to Go 1.10 for lack of activity. |
If we don't return an error we have to decide between returning []byte{} and make([]byte, Size). Better to return an error and make the user understand what's going on. |
Hello there, I have come across a case where https://pkg.go.dev/debug/elf#File.DWARF fails because of this issue. The ELF file that I have, have a section |
It's implemented in https://go.dev/cl/375216 as to read from a |
Thanks. |
(*Section).Data fails to take section.Type == Type:elf.SHT_NOBITS into account, and will happily return anything in the file at the section file offset.
On certain ELF files, debug/elf will output non-zero data for .bss section.
For example, compile the following assembly file as a shared library:
This is because the .comment section happens to be after the .bss section.
Perhaps this is a user error, but I'm not entirely sure. And if it is indeed a bug of debug/elf, I'm not sure whether we should make it return
make([]byte, section.Size)
or just an error indicating that the section doesn't have file data. I'm leaning towards returning a zero byte slice./cc @ianlancetaylor
The text was updated successfully, but these errors were encountered: