Skip to content
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

debug/elf: add access to dynamic symbol table #8127

Closed
gopherbot opened this issue May 31, 2014 · 4 comments
Closed

debug/elf: add access to dynamic symbol table #8127

gopherbot opened this issue May 31, 2014 · 4 comments
Milestone

Comments

@gopherbot
Copy link

by lionghostshop:

What does 'go version' print?
go version go1.3beta2 linux/amd64
What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. I use GO's API to read ELF file http://golang.org/pkg/debug/elf/#File.Symbols


What happened?
It reports no symbole table is found in the file. However, the file is valid. All those
files are included in Fedora linux.

What should have happened instead?
Should work like readelf command
Please provide any additional information below.
I provide one example of such elf files.

Attachments:

  1. libdb-5.3.so (1838024 bytes)
@ianlancetaylor
Copy link
Contributor

Comment 1:

readelf is displaying the dynamic symbol table.  The debug/elf package reads the normal
symbol table.
Still, there should be some way to use debug/elf to read the dynamic symbol table.

Labels changed: added repo-main, release-go1.4.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 15, 2014

Comment 2:

Labels changed: added release-go1.5, removed release-go1.4.

@dspezia
Copy link
Contributor

dspezia commented May 2, 2015

It seems dynamic symbols reading was implemented with the following commit:

commit f5b600f70cbe1e504a7623a7e0636535c49ea6c8
Author: Pietro Gagliardi <pietro10@mac.com>
Date:   Thu Jul 10 12:44:40 2014 -0700

debug/elf: add (*File).DynamicSymbols, ErrNoSymbols, and tests for (*File).Symbols and (*File).DynamicSymbols, and formalize symbol order.

Added a complement to (*File).Symbols for the dynamic symbol table.
Would be useful, for instance, if seraching for certain shared objects
compatible with certain libraries (for instance, LADSPA requires an
exported symbol "ladspa_descriptor").

Added a variable ErrNoSymbols that canonicalizes a return from
(*File).Symbols and (*File).DyanmicSymbols if the file has no symbols.

Added tests for both (*File).Symbols and (*File).DynamicSymbols;
there was never a test for (*File).Symbols at all. A small C program using
libelf, included in the test data, was used to produce the golden
symbols to compare against.

As part of the requirements for testing, (*File).Symbols and (*File).DynamicSymbols now document the order in which the symbol tables are returned (in the order the symbols appear in the file).

All tests currently pass.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/107530043

Is there anything missing, or can this issue be closed?
Btw, it does not appear in the go1.4 release notes.

@ianlancetaylor
Copy link
Contributor

I will close the issue. Thanks for pointing it out.

I guess we forgot to put this in the release notes.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants