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 File.DynValue method to look up DynTag values #18681

Open
minux opened this issue Jan 17, 2017 · 3 comments
Open

debug/elf: add File.DynValue method to look up DynTag values #18681

minux opened this issue Jan 17, 2017 · 3 comments

Comments

@minux
Copy link
Member

minux commented Jan 17, 2017

Currently there is no method/function to convert elf.Symbol.Info to SymBind and SymType, even thought there is a function ST_INFO to convert SymBind and SymType into uint8.

We probably should have created a new type for Symbol.Info, but we can't do that before Go 2.

Therefore I propose the addition of the following two methods to elf.Symbol:

func (s Symbol) Bind() SymBind {
     return SymBind(s.Info >> 4)
}
func (s Symbol) Type() SymType {
    return SymType(s.Info & 0xf)
}

Perhaps we could also make elf.Symbol implement Stringer, but I'm not sure about the format yet. Any suggestions?

Additionally, the elf package looks like automated conversion from elf.h as it contains a lot of top-level functions will non-idiolmatic names (R_INFO, R_SYM32, etc.) without any docs. For Go 2, we should get rid of them, and turn them into proper methods with idiomatic names.

/cc @ianlancetaylor

@minux minux added the Proposal label Jan 17, 2017
@minux minux added this to the Proposal milestone Jan 17, 2017
@minux
Copy link
Member Author

minux commented Jan 17, 2017

I also have more proposed addition to the debug/elf package. Should I write a design docs instead? Or maintain a fork of debug/elf?

It's probably too heavyweight for such small additions. I will just list them here:

// DynValue returns the raw value for a given tag in the dynamic section.
func ((f *File) DynValue(tag DynTag) (uint64, error)

@rsc
Copy link
Contributor

rsc commented Jan 23, 2017

Currently there is no method/function to convert elf.Symbol.Info to SymBind and SymType

I think you missed elf.ST_BIND and elf.ST_TYPE.

@rsc rsc changed the title Proposal: introduce methods to debug/elf.Symbol to access Info proposal: debug/elf: add Symbol methods to access Info Jan 23, 2017
@rsc
Copy link
Contributor

rsc commented Jan 23, 2017

If you'd like to send a CL or file a separate issue for DynValue, that's fine. You might want to make the implementation build a cache to avoid every call being O(n). I also am not sure if the result should be uint64 or []uint64, but I'll leave it to the actual review. No need for a formal proposal for that.

Will retitle for DynValue and accept.

@rsc rsc changed the title proposal: debug/elf: add Symbol methods to access Info proposal: debug/elf: add File.DynValue method to look up DynTag values Jan 23, 2017
@rsc rsc modified the milestones: Unplanned, Proposal Jan 23, 2017
@rsc rsc changed the title proposal: debug/elf: add File.DynValue method to look up DynTag values debug/elf: add File.DynValue method to look up DynTag values Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants