[PATCH] D110277: [compiler-rt][profile] Make corrupted-profile.c more robuset
Leonard Chan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 23 17:18:06 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc579c658cd42: [compiler-rt][profile] Make corrupted-profile.c more robust (authored by leonardchan).
Changed prior to commit:
https://reviews.llvm.org/D110277?vs=374687&id=374697#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110277/new/
https://reviews.llvm.org/D110277
Files:
compiler-rt/test/profile/Linux/corrupted-profile.c
Index: compiler-rt/test/profile/Linux/corrupted-profile.c
===================================================================
--- compiler-rt/test/profile/Linux/corrupted-profile.c
+++ compiler-rt/test/profile/Linux/corrupted-profile.c
@@ -19,6 +19,21 @@
#include <fcntl.h>
#include <unistd.h>
+enum ValueKind {
+#define VALUE_PROF_KIND(Enumerator, Value, Descr) Enumerator = Value,
+#include "profile/InstrProfData.inc"
+};
+
+typedef struct __llvm_profile_header {
+#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer) Type Name;
+#include "profile/InstrProfData.inc"
+} __llvm_profile_header;
+
+typedef void *IntPtrT;
+typedef struct __llvm_profile_data {
+#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
+#include "profile/InstrProfData.inc"
+} __llvm_profile_data;
void __llvm_profile_set_file_object(FILE* File, int EnableMerge);
@@ -42,10 +57,11 @@
if (Buf == MAP_FAILED)
bail("mmap");
- // We're trying to make the first CounterPtr invalid.
- // 11 64-bit words as header.
- // CounterPtr is the third 64-bit word field.
- memset(&Buf[11 * 8 + 2 * 8], 0xAB, 8);
+ __llvm_profile_header *Header = (__llvm_profile_header *)Buf;
+ __llvm_profile_data *SrcDataStart =
+ (__llvm_profile_data *)(Buf + sizeof(__llvm_profile_header) +
+ Header->BinaryIdsSize);
+ memset(&SrcDataStart->CounterPtr, 0xAB, sizeof(SrcDataStart->CounterPtr));
if (munmap(Buf, FileSize))
bail("munmap");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110277.374697.patch
Type: text/x-patch
Size: 1503 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210924/ce1250ab/attachment.bin>
More information about the llvm-commits
mailing list