Give error on binaries containing GC objc image infos.

The image info struct contains flags for what kind of GC/retain/release is required.

Give an error if we parse GC flags as these are unsupported.

llvm-svn: 257974
This commit is contained in:
Pete Cooper 2016-01-16 00:57:07 +00:00
parent 47936761b8
commit 4b6bed98e2
2 changed files with 32 additions and 4 deletions

View File

@ -892,10 +892,12 @@ std::error_code parseObjCImageInfo(const NormalizedFile &normalizedFile,
// uint32_t version; // initially 0
// uint32_t flags;
// };
// #define OBJC_IMAGE_SUPPORTS_GC 2
// #define OBJC_IMAGE_GC_ONLY 4
// #define OBJC_IMAGE_IS_SIMULATED 32
//
enum {
OBJC_IMAGE_SUPPORTS_GC=2,
OBJC_IMAGE_GC_ONLY=4,
OBJC_IMAGE_IS_SIMULATED=32,
};
ArrayRef<uint8_t> content = imageInfoSection->content;
if (content.size() != 8)
return make_dynamic_error_code(imageInfoSection->segmentName + "/" +
@ -912,6 +914,12 @@ std::error_code parseObjCImageInfo(const NormalizedFile &normalizedFile,
" should have version=0");
uint32_t flags = read32(content.data() + 4, isBig);
if (flags & (OBJC_IMAGE_SUPPORTS_GC|OBJC_IMAGE_GC_ONLY))
return make_dynamic_error_code(imageInfoSection->segmentName + "/" +
imageInfoSection->sectionName +
" in file " + file.path() +
" uses GC. This is not supported");
file.setSwiftVersion((flags >> 8) & 0xFF);
return std::error_code();

View File

@ -0,0 +1,20 @@
# RUN: not lld -flavor darwin -arch x86_64 -r %s 2>&1 | FileCheck %s
--- !mach-o
arch: x86_64
file-type: MH_OBJECT
flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ]
compat-version: 0.0
current-version: 0.0
has-UUID: false
OS: unknown
sections:
- segment: __DATA
section: __objc_imageinfo
type: S_REGULAR
attributes: [ S_ATTR_NO_DEAD_STRIP ]
address: 0x0000000000000100
content: [ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00 ]
...
# CHECK: error: __DATA/__objc_imageinfo in file {{.*}} uses GC. This is not supported