From 8404c21b6eb07ff7699ed76c45037fcfdf83c43b Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Wed, 27 Feb 2019 17:10:59 +0100 Subject: [PATCH 1/7] Add debug assertions to write_bytes and copy* --- src/libcore/intrinsics.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 782a7ba455984..5acf2cbffcf91 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -41,6 +41,8 @@ since = "1.18.0")] pub use crate::ptr::drop_in_place; +use crate::mem; + extern "rust-intrinsic" { // N.B., these intrinsics take raw pointers because they mutate aliased // memory, which is not valid for either `&` or `&mut`. @@ -1323,6 +1325,29 @@ mod real_intrinsics { } } +/// Checks whether `ptr` is properly aligned with respect to +/// `align_of::()`. +fn is_aligned(ptr: *const T) -> bool { + return ptr as usize % mem::align_of::() == 0; +} + +/// Checks whether the regions of memory starting at `src` and `dst` of size +/// `count * size_of::()` overlap. +fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { + use crate::cmp::Ordering; + let src_usize = src as usize; + let dst_usize = dst as usize; + let size = mem::size_of::() * count; + match src_usize.cmp(&dst_usize) { + // src < dst < src + offset + Ordering::Less => src_usize + size > dst_usize, + // dst < src < dst + offset + Ordering::Greater => dst_usize + size > src_usize, + // src == dst + Ordering::Equal => count != 0, + } +} + /// Copies `count * size_of::()` bytes from `src` to `dst`. The source /// and destination must *not* overlap. /// @@ -1409,6 +1434,9 @@ mod real_intrinsics { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { + debug_assert!(is_aligned(src), "attempt to copy from unaligned pointer"); + debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); + debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory"); real_intrinsics::copy_nonoverlapping(src, dst, count); } @@ -1466,6 +1494,13 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { + debug_assert!(is_aligned(src), "attempt to copy from unaligned pointer"); + debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); + let src_usize = src as usize; + let dst_usize = dst as usize; + let size = mem::size_of::() * count; + debug_assert!(dst_usize < src_usize || dst_usize + size >= src_usize, + "attempt to copy to a destination overlapping with the source"); real_intrinsics::copy(src, dst, count) } @@ -1544,5 +1579,6 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { + debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); real_intrinsics::write_bytes(dst, val, count) } From 5ff7f6ebbddbbf097e5fef94188f50c6f9a93a48 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Thu, 28 Feb 2019 13:52:30 +0100 Subject: [PATCH 2/7] Address comments --- src/libcore/intrinsics.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 5acf2cbffcf91..311c3c33f2625 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1327,8 +1327,8 @@ mod real_intrinsics { /// Checks whether `ptr` is properly aligned with respect to /// `align_of::()`. -fn is_aligned(ptr: *const T) -> bool { - return ptr as usize % mem::align_of::() == 0; +fn is_aligned_and_not_null(ptr: *const T) -> bool { + return !ptr.is_null() && ptr as usize % mem::align_of::() == 0; } /// Checks whether the regions of memory starting at `src` and `dst` of size @@ -1344,7 +1344,7 @@ fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { // dst < src < dst + offset Ordering::Greater => dst_usize + size > src_usize, // src == dst - Ordering::Equal => count != 0, + Ordering::Equal => size != 0, } } @@ -1434,8 +1434,8 @@ fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { - debug_assert!(is_aligned(src), "attempt to copy from unaligned pointer"); - debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned pointer"); debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory"); real_intrinsics::copy_nonoverlapping(src, dst, count); } @@ -1494,8 +1494,8 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { - debug_assert!(is_aligned(src), "attempt to copy from unaligned pointer"); - debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned pointer"); let src_usize = src as usize; let dst_usize = dst as usize; let size = mem::size_of::() * count; @@ -1579,6 +1579,6 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { - debug_assert!(is_aligned(dst), "attempt to copy to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned pointer"); real_intrinsics::write_bytes(dst, val, count) } From 7cdf05152eb2b6cd974090c1c8263ece6ffdd476 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Thu, 28 Feb 2019 14:52:56 +0100 Subject: [PATCH 3/7] Remove copy overlap checks --- src/libcore/intrinsics.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 311c3c33f2625..e2291a1f93ed4 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1496,11 +1496,6 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned pointer"); debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned pointer"); - let src_usize = src as usize; - let dst_usize = dst as usize; - let size = mem::size_of::() * count; - debug_assert!(dst_usize < src_usize || dst_usize + size >= src_usize, - "attempt to copy to a destination overlapping with the source"); real_intrinsics::copy(src, dst, count) } From ae1eb5133a44539d98338c78b6a015626342ff0f Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Thu, 28 Feb 2019 15:48:36 +0100 Subject: [PATCH 4/7] share is_aligned_and_not_null with slice --- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/embedded-book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/doc/rustc-guide | 2 +- src/libcore/intrinsics.rs | 12 ++++++------ src/libcore/slice/mod.rs | 5 +++-- src/llvm-project | 2 +- src/stdsimd | 2 +- src/tools/cargo | 2 +- src/tools/clippy | 2 +- src/tools/miri | 2 +- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 16 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/doc/book b/src/doc/book index db919bc6bb907..9cffbeabec3bc 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit db919bc6bb9071566e9c4f05053672133eaac33e +Subproject commit 9cffbeabec3bcec42d09432bfe7705125c848889 diff --git a/src/doc/edition-guide b/src/doc/edition-guide index c413d42a207bd..aa0022c875907 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit c413d42a207bd082f801ec0137c31b71e4bfed4c +Subproject commit aa0022c875907886cae8f3ef8e9ebf6e2a5e728d diff --git a/src/doc/embedded-book b/src/doc/embedded-book index de3d55f521e65..9e656ead82bfe 160000 --- a/src/doc/embedded-book +++ b/src/doc/embedded-book @@ -1 +1 @@ -Subproject commit de3d55f521e657863df45260ebbca1b10527f662 +Subproject commit 9e656ead82bfe869493dec82653a52e27fa6a05c diff --git a/src/doc/nomicon b/src/doc/nomicon index fb29b147be4d9..f1ff93b668444 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit fb29b147be4d9a1f8e24aba753a7e1de537abf61 +Subproject commit f1ff93b66844493a7b03101c7df66ac958c62418 diff --git a/src/doc/reference b/src/doc/reference index 2a2de9ce09597..41493ffce5d0e 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 2a2de9ce095979978ad7b582daecf94e4070b916 +Subproject commit 41493ffce5d0e17d54eaf5ec9a995054e2b9aece diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 1ff0f8e018838..2ce92beabb912 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 1ff0f8e018838a710ebc0cc1a7bf74ebe73ad9f1 +Subproject commit 2ce92beabb912d417a7314d6da83ac9b50dc2afb diff --git a/src/doc/rustc-guide b/src/doc/rustc-guide index 99e1b1d53656b..344c4e437ba4c 160000 --- a/src/doc/rustc-guide +++ b/src/doc/rustc-guide @@ -1 +1 @@ -Subproject commit 99e1b1d53656be08654df399fc200584aebb50e4 +Subproject commit 344c4e437ba4cfa5c14db643ec4d6b68dcd164c5 diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index e2291a1f93ed4..ea807cbaeae22 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1327,7 +1327,7 @@ mod real_intrinsics { /// Checks whether `ptr` is properly aligned with respect to /// `align_of::()`. -fn is_aligned_and_not_null(ptr: *const T) -> bool { +pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { return !ptr.is_null() && ptr as usize % mem::align_of::() == 0; } @@ -1434,8 +1434,8 @@ fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { - debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned pointer"); - debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); debug_assert!(!overlaps(src, dst, count), "attempt to copy to overlapping memory"); real_intrinsics::copy_nonoverlapping(src, dst, count); } @@ -1494,8 +1494,8 @@ pub unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { - debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned pointer"); - debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(src), "attempt to copy from unaligned or null pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to copy to unaligned or null pointer"); real_intrinsics::copy(src, dst, count) } @@ -1574,6 +1574,6 @@ pub unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { - debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned pointer"); + debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer"); real_intrinsics::write_bytes(dst, val, count) } diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 8731f48675356..593ca4d8160b6 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -26,6 +26,7 @@ use crate::cmp::Ordering::{self, Less, Equal, Greater}; use crate::cmp; use crate::fmt; use crate::intrinsics::assume; +use crate::intrinsics::is_aligned_and_not_null; use crate::isize; use crate::iter::*; use crate::ops::{FnMut, Try, self}; @@ -5084,7 +5085,7 @@ unsafe impl<'a, T> TrustedRandomAccess for RChunksExactMut<'a, T> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); Repr { raw: FatPtr { data, len } }.rust @@ -5105,7 +5106,7 @@ pub unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn from_raw_parts_mut<'a, T>(data: *mut T, len: usize) -> &'a mut [T] { - debug_assert!(data as usize % mem::align_of::() == 0, "attempt to create unaligned slice"); + debug_assert!(is_aligned_and_not_null(data), "attempt to create unaligned or null slice"); debug_assert!(mem::size_of::().saturating_mul(len) <= isize::MAX as usize, "attempt to create slice covering half the address space"); Repr { raw: FatPtr { data, len } }.rust_mut diff --git a/src/llvm-project b/src/llvm-project index 84abffda0e03b..4fc9fb8245abe 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 84abffda0e03b03c62bdfc3cfeda1c2cf1f88c85 +Subproject commit 4fc9fb8245abe24680192535870c4522644a4212 diff --git a/src/stdsimd b/src/stdsimd index 4bf456c35e85f..359845eb7cae8 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 4bf456c35e85fcca5cf95008401af8ab25abf850 +Subproject commit 359845eb7cae85799dc2ec81f2fb05da0aa6276d diff --git a/src/tools/cargo b/src/tools/cargo index 6be12653dcefb..0e35bd8af0ec7 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 6be12653dcefb46ee7b605f063ee75b5e6cba513 +Subproject commit 0e35bd8af0ec72d3225c4819b330b94628f0e9d0 diff --git a/src/tools/clippy b/src/tools/clippy index 8c0e038f6f25e..016d92d6ed5ae 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 8c0e038f6f25e0d8db8e24bcd37b4b11ca9665c6 +Subproject commit 016d92d6ed5ae8a3785b65aa300768abbc26f818 diff --git a/src/tools/miri b/src/tools/miri index 7d7cf4d42e414..72b4ee0381dec 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 7d7cf4d42e41437f5a5b04a6b8dd567f330ae6ee +Subproject commit 72b4ee0381decf609204e5548c1f5e79bdfb18b7 diff --git a/src/tools/rls b/src/tools/rls index 20e32686df573..6840dd69af3ad 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 20e32686df573fc44ac1052bf3e6982b0da27cfc +Subproject commit 6840dd69af3ada1f8a432075f1f0be679ea8a468 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index b860feaffccb8..d6829d62dca64 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit b860feaffccb81199c045e9b1511c2e25825dc0c +Subproject commit d6829d62dca64dfe7ceaa96d1a9c1cd36428221d From 5d25e504c4ba77349c20439816b06619be5d8cc1 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Wed, 20 Mar 2019 17:25:52 +0100 Subject: [PATCH 5/7] Change overlaps to use the absolute difference instead --- src/libcore/intrinsics.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index ea807cbaeae22..d706651eff5eb 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1337,15 +1337,13 @@ fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { use crate::cmp::Ordering; let src_usize = src as usize; let dst_usize = dst as usize; - let size = mem::size_of::() * count; - match src_usize.cmp(&dst_usize) { - // src < dst < src + offset - Ordering::Less => src_usize + size > dst_usize, - // dst < src < dst + offset - Ordering::Greater => dst_usize + size > src_usize, - // src == dst - Ordering::Equal => size != 0, - } + let size = mem::size_of::().checked_mul(count).unwrap(); + let diff = if src_usize > dst_usize { + src_usize - dst_usize + } else { + dst_usize - src_usize + }; + diff > size; } /// Copies `count * size_of::()` bytes from `src` to `dst`. The source From 12e1776ffcf1d2eaa9f59d1eed7951ec0fdcefaf Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 20 Mar 2019 18:19:46 +0100 Subject: [PATCH 6/7] Fix the return condition Co-Authored-By: nitnelave --- src/libcore/intrinsics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index d706651eff5eb..258560cb7f13a 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1343,7 +1343,7 @@ fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { } else { dst_usize - src_usize }; - diff > size; + size > diff } /// Copies `count * size_of::()` bytes from `src` to `dst`. The source From 8590190e3fdab1a7833e2a59b7e1b70ab29fd1f6 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Wed, 27 Mar 2019 15:57:14 +0100 Subject: [PATCH 7/7] Handle null from LLVMRustGetSectionName --- src/libcore/intrinsics.rs | 1 - src/librustc_codegen_llvm/llvm/ffi.rs | 4 +++- src/librustc_codegen_llvm/metadata.rs | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 258560cb7f13a..bd7570d0f68f4 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1334,7 +1334,6 @@ pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { /// Checks whether the regions of memory starting at `src` and `dst` of size /// `count * size_of::()` overlap. fn overlaps(src: *const T, dst: *const T, count: usize) -> bool { - use crate::cmp::Ordering; let src_usize = src as usize; let dst_usize = dst as usize; let size = mem::size_of::().checked_mul(count).unwrap(); diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index f88923fc9f1c5..01fe1afd51e2c 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -1706,7 +1706,9 @@ extern "C" { pub fn LLVMRustArchiveIteratorFree(AIR: &'a mut ArchiveIterator<'a>); pub fn LLVMRustDestroyArchive(AR: &'static mut Archive); - pub fn LLVMRustGetSectionName(SI: &SectionIterator<'_>, data: &mut *const c_char) -> size_t; + #[allow(improper_ctypes)] + pub fn LLVMRustGetSectionName(SI: &SectionIterator<'_>, + data: &mut Option>) -> size_t; #[allow(improper_ctypes)] pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString); diff --git a/src/librustc_codegen_llvm/metadata.rs b/src/librustc_codegen_llvm/metadata.rs index 7cf497cb5d036..9bddd29d2e88f 100644 --- a/src/librustc_codegen_llvm/metadata.rs +++ b/src/librustc_codegen_llvm/metadata.rs @@ -8,7 +8,6 @@ use rustc_data_structures::owning_ref::OwningRef; use rustc_codegen_ssa::METADATA_FILENAME; use std::path::Path; -use std::ptr; use std::slice; use rustc_fs_util::path_to_c_string; @@ -67,10 +66,14 @@ fn search_meta_section<'a>(of: &'a ObjectFile, unsafe { let si = mk_section_iter(of.llof); while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False { - let mut name_buf = ptr::null(); + let mut name_buf = None; let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf); - let name = slice::from_raw_parts(name_buf as *const u8, name_len as usize).to_vec(); - let name = String::from_utf8(name).unwrap(); + let name = name_buf.map_or( + "".to_string(), + |buf| String::from_utf8( + slice::from_raw_parts(buf.as_ptr() as *const u8, + name_len as usize) + .to_vec()).unwrap()); debug!("get_metadata_section: name {}", name); if read_metadata_section_name(target) == name { let cbuf = llvm::LLVMGetSectionContents(si.llsi);