From d99dfda6652eb39aa2e3af012bb2d467a726de34 Mon Sep 17 00:00:00 2001 From: Edward Humes Date: Wed, 22 Mar 2023 13:28:29 -0400 Subject: [PATCH] Ensure SYMTAB in rlib's with arch code but no syms --- src/archive_writer.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/archive_writer.rs b/src/archive_writer.rs index 73c1121..dbd8c62 100644 --- a/src/archive_writer.rs +++ b/src/archive_writer.rs @@ -408,12 +408,17 @@ fn write_symbols( has_object: &mut bool, ) -> io::Result> { let mut ret = vec![]; - *has_object = get_symbols(buf, &mut |sym| { + // We only set has_object if get_symbols determines it's looking at an + // object file. This is because if we're creating an rlib, the archive will + // always end in lib.rmeta, and cause has_object to always become false. + if get_symbols(buf, &mut |sym| { ret.push(sym_names.stream_position()?); sym_names.write_all(sym)?; sym_names.write_all(&[0])?; Ok(()) - })?; + })? { + *has_object = true; + } Ok(ret) }