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

Add support for XCOFF #635

Merged
merged 3 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ pub enum SectionId {

impl SectionId {
/// Returns the ELF section name for this kind.
#[cfg(not(target_os = "aix"))]
pub fn name(self) -> &'static str {
match self {
SectionId::DebugAbbrev => ".debug_abbrev",
Expand Down Expand Up @@ -318,6 +319,35 @@ impl SectionId {
}
}

/// Returns the XCOFF section name for this kind.
#[cfg(target_os = "aix")]
philipc marked this conversation as resolved.
Show resolved Hide resolved
pub fn name(self) -> &'static str {
match self {
SectionId::DebugAbbrev => ".dwabrev",
SectionId::DebugAddr => panic!("XCOFF doesn't have debug address section"),
philipc marked this conversation as resolved.
Show resolved Hide resolved
SectionId::DebugAranges => ".dwarnge",
SectionId::DebugCuIndex => panic!("XCOFF doesn't have debug cu index section"),
SectionId::DebugFrame => ".dwframe",
SectionId::EhFrame => panic!("XCOFF doesn't have eh frame section"),
SectionId::EhFrameHdr => panic!("XCOFF doesn't have eh frame hdr section"),
SectionId::DebugInfo => ".dwinfo",
SectionId::DebugLine => ".dwline",
SectionId::DebugLineStr => panic!("XCOFF doesn't have debug line string section"),
SectionId::DebugLoc => ".dwloc",
SectionId::DebugLocLists => panic!("XCOFF doesn't have debug loc lists section"),
SectionId::DebugMacinfo => ".dwmac",
SectionId::DebugMacro => panic!("XCOFF doesn't have debug macro section"),
SectionId::DebugPubNames => ".dwpbnms",
SectionId::DebugPubTypes => ".dwpbtyp",
SectionId::DebugRanges => ".dwrnges",
SectionId::DebugRngLists => panic!("XCOFF doesn't have debug range lists section"),
SectionId::DebugStr => ".dwstr",
SectionId::DebugStrOffsets => panic!("XCOFF doesn't have debug str offsets section"),
SectionId::DebugTuIndex => panic!("XCOFF doesn't have debug tu index section"),
SectionId::DebugTypes => panic!("XCOFF doesn't have debug type section"),
}
}

/// Returns the ELF section name for this kind, when found in a .dwo or .dwp file.
pub fn dwo_name(self) -> Option<&'static str> {
Some(match self {
Expand Down
30 changes: 22 additions & 8 deletions src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,19 +1129,33 @@ mod tests {
match dwarf.debug_str.get_str(DebugStrOffset(1)) {
Ok(r) => panic!("Unexpected str {:?}", r),
Err(e) => {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .debug_str+0x1"
);
if cfg!(not(target_os = "aix")) {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .debug_str+0x1"
);
} else {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .dwstr+0x1"
);
}
}
}
match dwarf.sup().unwrap().debug_str.get_str(DebugStrOffset(1)) {
Ok(r) => panic!("Unexpected str {:?}", r),
Err(e) => {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .debug_str(sup)+0x1"
);
if cfg!(not(target_os = "aix")) {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .debug_str(sup)+0x1"
);
} else {
assert_eq!(
dwarf.format_error(e),
"Hit the end of input before it was expected at .dwstr(sup)+0x1"
);
}
}
}
assert_eq!(dwarf.format_error(Error::Io), Error::Io.description());
Expand Down