inkwell
inkwell copied to clipboard
`GlobalValue::get_section` can segfault if there is no section on the global
Describe the Bug
LLVMGetSection returns a null pointer if the global does not have a section set on it. This means that GlobalValue::get_section should return Option<&CStr> rather than &CStr, and check whether null was returned and return None in that case. Similarly, GlobalValue::set_section should take Option<&CStr> to allow you to remove the section by passing None.
To Reproduce
Get a handle to a GlobalValue with no section set. Call get_section() on it. Segfault.
Expected Behavior
Function should check whether LLVMGetSection returns null.
LLVM Version (please complete the following information):
- LLVM Version: 10
- Inkwell Branch Used: master
Desktop (please complete the following information): Windows 10
Additional Context N/A