Research Article

Tag-Protector: An Effective and Dynamic Detection of Illegal Memory Accesses through Compile Time Code Instrumentation

Algorithm 2

Stage 2: tag creation for globally declared memory objects by tag-protection pass.
Input: Instrumented LLVM-IR code generated in stage-1 of tag-protection pass
Output: Instrumented LLVM-IR code generated through LLVM opt command using stage-2 of tag-protection pass
Create dedicated tag address ; Create .
for each global memory object in do
 if is not a pointer memory object then
  if is an array memory object then
   Find start and end address, create and mark pointers and assign
   them start and end addresses.
   Store memory object , its type and tag marks information in
  end
 else
  Create tag_start and tag_end mark pointers and initialize them with NULL value.
  Store memory object , its type and tag information in
 end
 if is a structure memory object then
  for each variable   in do
   if is not a pointer memory object then
    if is an array memory object then
     Find start and end address, create and mark pointers and assign them start and end addresses.
     Store memory object , its type, index and tag marks information in
    end
   else
    Create and mark pointers and initialize them with NULL value.
    Store memory object , its type, index and tag marks
    information in
   end
  end
 end
end
Save modified LLVM-IR code saved as semi instrumented LLVM-IR code