File tree 1 file changed +5
-6
lines changed
compiler/rustc_session/src
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -89,9 +89,8 @@ fn current_dll_path() -> Result<PathBuf, String> {
89
89
// * The address of the entry point of the function.
90
90
// * The TOC base address for the function.
91
91
// * The environment pointer.
92
- // Deref `current_dll_path` directly so that we can get the address of `current_dll_path`'s
93
- // entry point in text section.
94
- let addr = * ( current_dll_path as * const u64 ) ;
92
+ // The function descriptor is in the data section.
93
+ let addr = current_dll_path as u64 ;
95
94
let mut buffer = vec ! [ std:: mem:: zeroed:: <libc:: ld_info>( ) ; 64 ] ;
96
95
loop {
97
96
if libc:: loadquery (
@@ -110,9 +109,9 @@ fn current_dll_path() -> Result<PathBuf, String> {
110
109
}
111
110
let mut current = buffer. as_mut_ptr ( ) as * mut libc:: ld_info ;
112
111
loop {
113
- let text_base = ( * current) . ldinfo_textorg as u64 ;
114
- let text_end = text_base + ( * current) . ldinfo_textsize ;
115
- if ( text_base..text_end ) . contains ( & addr) {
112
+ let data_base = ( * current) . ldinfo_dataorg as u64 ;
113
+ let data_end = data_base + ( * current) . ldinfo_datasize ;
114
+ if ( data_base..data_end ) . contains ( & addr) {
116
115
let bytes = CStr :: from_ptr ( & ( * current) . ldinfo_filename [ 0 ] ) . to_bytes ( ) ;
117
116
let os = OsStr :: from_bytes ( bytes) ;
118
117
return Ok ( PathBuf :: from ( os) ) ;
You can’t perform that action at this time.
0 commit comments