Do not write a DWARF section if it is empty
There is no point in writing an empty DWARF section, and this will make our ELF files a tiny bit smaller.
This commit is contained in:
@@ -54,6 +54,9 @@ fn emit_dwarf_sections(
|
|||||||
sections.for_each_mut(|id, s| -> anyhow::Result<()> {
|
sections.for_each_mut(|id, s| -> anyhow::Result<()> {
|
||||||
let name = id.name();
|
let name = id.name();
|
||||||
let body = s.writer.take();
|
let body = s.writer.take();
|
||||||
|
if body.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let mut relocs = vec![];
|
let mut relocs = vec![];
|
||||||
::std::mem::swap(&mut relocs, &mut s.relocs);
|
::std::mem::swap(&mut relocs, &mut s.relocs);
|
||||||
result.push(DwarfSection { name, body, relocs });
|
result.push(DwarfSection { name, body, relocs });
|
||||||
|
|||||||
Reference in New Issue
Block a user