byte[] GetSectionContents(IntPtr section)
{
int size = bfd_glue_get_section_size (section);
IntPtr data = IntPtr.Zero;
try {
data = Marshal.AllocHGlobal (size);
if (!bfd_glue_get_section_contents (bfd, section, data, size)) {
string error = bfd_glue_get_errormsg ();
string name = bfd_glue_get_section_name (section);
throw new SymbolTableException (
"Can't read bfd section {0}: {1}", name, error);
}
byte[] retval = new byte [size];
Marshal.Copy (data, retval, 0, size);
return retval;
} finally {
Marshal.FreeHGlobal (data);
}
}