Skip to content

Commit 68088c5

Browse files
Ensure that section names on macOS are under 16 characters.
1 parent 338c548 commit 68088c5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

macros/src/construct.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ pub(crate) fn interned_string(
6363
pub(crate) fn linker_section(for_macos: bool, prefix: Option<&str>, symbol: &str) -> String {
6464
let symbol_hash = hash(symbol);
6565
let suffix = if for_macos {
66-
// The Apple linker doesn't like `.` in input section names
66+
// "mach-o section specifier requires a section whose length is between 1 and 16 characters."
6767
if let Some(prefix) = prefix {
68-
format!(",{prefix}_{symbol_hash:x}")
68+
let intermediate = format!("{prefix}_{symbol_hash:08x}");
69+
format!(",{intermediate:.16}")
6970
} else {
70-
format!(",{symbol_hash:x}")
71+
format!(",{symbol_hash:08x}")
7172
}
7273
} else {
7374
if let Some(prefix) = prefix {

0 commit comments

Comments
 (0)