{"action":"created","issue":{"url":"https://api.github.com/repos/m4b/goblin/issues/22","repository_url":"https://api.github.com/repos/m4b/goblin","labels_url":"https://api.github.com/repos/m4b/goblin/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/m4b/goblin/issues/22/comments","events_url":"https://api.github.com/repos/m4b/goblin/issues/22/events","html_url":"https://github.com/m4b/goblin/issues/22","id":226953929,"number":22,"title":"goblin::mach::load_command::Segment::sections() returns sections with wrong lifetime","user":{"login":"philipc","id":330342,"avatar_url":"https://avatars1.githubusercontent.com/u/330342?v=3","gravatar_id":"","url":"https://api.github.com/users/philipc","html_url":"https://github.com/philipc","followers_url":"https://api.github.com/users/philipc/followers","following_url":"https://api.github.com/users/philipc/following{/other_user}","gists_url":"https://api.github.com/users/philipc/gists{/gist_id}","starred_url":"https://api.github.com/users/philipc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipc/subscriptions","organizations_url":"https://api.github.com/users/philipc/orgs","repos_url":"https://api.github.com/users/philipc/repos","events_url":"https://api.github.com/users/philipc/events{/privacy}","received_events_url":"https://api.github.com/users/philipc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-05-08T06:50:16Z","updated_at":"2017-05-09T10:16:27Z","closed_at":null,"body":"I'm trying to use goblin as the object file loader in the gimli crate. Basically all it needs to do is parse the ELF/Mach-O header and return the data for sections with a given name.\r\n\r\nHowever, I'm having trouble getting Mach-O sections, because `Segment::sections()` returns sections that have the lifetime of the segment, instead of the data. That is, `Segment::sections()` is defined as:\r\n````\r\nimpl<'a> Segment<'a>\r\n    pub fn sections<'b>(&'b self) -> error::Result<Vec<Section<'b>>> {\r\n        ...\r\n    }\r\n}\r\n````\r\n\r\nbut I want:\r\n````\r\nimpl<'a> Segment<'a>\r\n    pub fn sections<'b>(&'b self) -> error::Result<Vec<Section<'a>>> {\r\n        ...\r\n    }\r\n}\r\n````\r\n\r\nFixing this will probably require changing the `scroll::Gread` trait, but I'm having too much trouble understanding how that works to be able to fix it myself.\r\n\r\nFor reference, here's how I'm trying to call it:\r\n````\r\nfn macho_get_section<'a>(macho: &mach::MachO<'a>, section_name: &str) -> Option<&'a [u8]> {\r\n    let segment_name = \"__DWARF\";\r\n    let section_name = macho_translate_section_name(section_name);\r\n\r\n    for segment in &*macho.segments {\r\n        if let Ok(name) = segment.name() {\r\n            if name == segment_name {\r\n                if let Ok(sections) = segment.sections() {\r\n                    for section in sections {\r\n                        if section_name == parse_section_name(&section.sectname[..]) {\r\n                            return Some(section.data);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n    None\r\n}\r\n````\r\n"},"comment":{"url":"https://api.github.com/repos/m4b/goblin/issues/comments/300122218","html_url":"https://github.com/m4b/goblin/issues/22#issuecomment-300122218","issue_url":"https://api.github.com/repos/m4b/goblin/issues/22","id":300122218,"user":{"login":"philipc","id":330342,"avatar_url":"https://avatars1.githubusercontent.com/u/330342?v=3","gravatar_id":"","url":"https://api.github.com/users/philipc","html_url":"https://github.com/philipc","followers_url":"https://api.github.com/users/philipc/followers","following_url":"https://api.github.com/users/philipc/following{/other_user}","gists_url":"https://api.github.com/users/philipc/gists{/gist_id}","starred_url":"https://api.github.com/users/philipc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipc/subscriptions","organizations_url":"https://api.github.com/users/philipc/orgs","repos_url":"https://api.github.com/users/philipc/repos","events_url":"https://api.github.com/users/philipc/events{/privacy}","received_events_url":"https://api.github.com/users/philipc/received_events","type":"User","site_admin":false},"created_at":"2017-05-09T10:16:27Z","updated_at":"2017-05-09T10:16:27Z","body":"Thanks for the quick fix; that fixes compilation for me. I haven't actually tested that it executes properly yet though, because I don't have access to any Mach-O binaries with DWARF debug info to test with. I hope to resolve that soon."}}
{"actor":{"display_login":"philipc"}}