You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On macOS LLVM emits __TEXT,__eh_frame sections with the DW_GNU_EH_PE_pcrel + DW_GNU_EH_PE_absptr pointer encoding and without relocations. This means that the pointers are encoded as the difference between the target address and the pointer address. There currently isn't any way to apply the relocations of these pointers while writing the object files as required by the macOS linker (it simply ignores relocations to this section when rewriting it during linking). It isn't possible to get the address of the __eh_frame and __text sections before emitting the object file to manually relocate it before handing it over to object. How should this best be handled?
The text was updated successfully, but these errors were encountered:
rust_out.rust_out.3a1fbbbh-cgu.0.rcgu.o.gz (had to gzip it for github to accept it.) Produced using echo '#![feature(no_core, lang_items)] #![no_core] #[lang = "sized"] trait Sized {} extern "Rust" { fn foo(); } pub unsafe fn bar() { foo(); }' | RUSTC_BOOTSTRAP=1 rustc --target x86_64-apple-darwin - -Cembed-bitcode=no -Csave-temps --crate-type lib. Using unstable features to produce an as smal as possible object file and to not have to install the standard library for macOS.
We need to apply these relocations during writing in write::Object::write_macho.
I'm not sure if this should be done automatically (based on section name or a new section kind), or requested by the user (flag for section or target symbol or individual relocation). The implementation in LLVM seems to handle this by setting the relocation target symbol to a temporary symbol that isn't emitted.
Will the __eh_frame section ever have other relocations that shouldn't be applied before writing? It looks like LSDA pointers need to be handled the same way, but I'm not sure about personality functions.
On macOS LLVM emits
__TEXT,__eh_frame
sections with the DW_GNU_EH_PE_pcrel + DW_GNU_EH_PE_absptr pointer encoding and without relocations. This means that the pointers are encoded as the difference between the target address and the pointer address. There currently isn't any way to apply the relocations of these pointers while writing the object files as required by the macOS linker (it simply ignores relocations to this section when rewriting it during linking). It isn't possible to get the address of the__eh_frame
and__text
sections before emitting the object file to manually relocate it before handing it over to object. How should this best be handled?The text was updated successfully, but these errors were encountered: