Cfi function attribute for codec factory
Declare cfi_canonical_jump_table for codec factory functions to avoid
cfi crashes.
Bug: 158010610
Bug: 173497308
Test: ran atest DecoderConformanceTest, ImageReaderDecoderTest,
VideoDecoderPerfTest, VideoEncoderTest. Compare the
before and after enabling CFI results since there was a number of tests
that were initially failing.
Change-Id: I66f75314c32aaa2d5009f74fc764528343c012a5
diff --git a/media/codec2/components/mp3/C2SoftMp3Dec.cpp b/media/codec2/components/mp3/C2SoftMp3Dec.cpp
index 5ba7e3d..7137767 100644
--- a/media/codec2/components/mp3/C2SoftMp3Dec.cpp
+++ b/media/codec2/components/mp3/C2SoftMp3Dec.cpp
@@ -539,11 +539,13 @@
} // namespace android
+__attribute__((cfi_canonical_jump_table))
extern "C" ::C2ComponentFactory* CreateCodec2Factory() {
ALOGV("in %s", __func__);
return new ::android::C2SoftMp3DecFactory();
}
+__attribute__((cfi_canonical_jump_table))
extern "C" void DestroyCodec2Factory(::C2ComponentFactory* factory) {
ALOGV("in %s", __func__);
delete factory;