Skip to content

Commit 09b8f72

Browse files
Rollup merge of rust-lang#153090 - mati865:elf-raw-dylib-fns, r=TaKO8Ki
elf-raw-dylib: set type for functions Avoids GNU ld warnings like: ``` type and size of dynamic symbol `meooooooooooooooow' are not defined ``` First noticed in rust-lang#152451 (comment) with changes from rust-lang#149937.
2 parents ad4b2c0 + 30fc9bd commit 09b8f72

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
271271
vers.push((version_name, dynstr));
272272
id
273273
};
274-
syms.push((name, dynstr, Some(ver)));
274+
syms.push((name, dynstr, Some(ver), symbol.is_fn));
275275
} else {
276276
let dynstr = stub.add_dynamic_string(symbol_name.as_bytes());
277-
syms.push((symbol_name, dynstr, None));
277+
syms.push((symbol_name, dynstr, None, symbol.is_fn));
278278
}
279279
}
280280

@@ -398,10 +398,11 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
398398

399399
// .dynsym
400400
stub.write_null_dynamic_symbol();
401-
for (_name, dynstr, _ver) in syms.iter().copied() {
401+
for (_name, dynstr, _ver, is_fn) in syms.iter().copied() {
402+
let sym_type = if is_fn { elf::STT_FUNC } else { elf::STT_NOTYPE };
402403
stub.write_dynamic_symbol(&write::Sym {
403404
name: Some(dynstr),
404-
st_info: (elf::STB_GLOBAL << 4) | elf::STT_NOTYPE,
405+
st_info: (elf::STB_GLOBAL << 4) | sym_type,
405406
st_other: elf::STV_DEFAULT,
406407
section: Some(text_section),
407408
st_shndx: 0, // ignored by object in favor of the `section` field
@@ -417,7 +418,7 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport]
417418
if !vers.is_empty() {
418419
// .gnu_version
419420
stub.write_null_gnu_versym();
420-
for (_name, _dynstr, ver) in syms.iter().copied() {
421+
for (_name, _dynstr, ver, _is_fn) in syms.iter().copied() {
421422
stub.write_gnu_versym(if let Some(ver) = ver {
422423
assert!((2 + ver as u16) < elf::VERSYM_HIDDEN);
423424
elf::VERSYM_HIDDEN | (2 + ver as u16)

0 commit comments

Comments
 (0)