Week 11 - Project Stage 2 : Introduction

Hamza TeliHamza Teli
2 min read

Hello everyone, in this article I will briefly cover what project stage 2 has in store for us and how I will be tackling this project. Because this project is complex, I will have a few articles as I make progress.

What is Project Stage 2?

Project Stage 2 also involves creating a custom GCC pass. This GCC pass must perform the following functions:

  1. Identify the functions that have been cloned

  2. Compare the cloned functions

  3. Print a message in the GCC dump for the functions that are the same stating they should be pruned.

Significance of Project 2?

Now you may be wondering why are we doing this? This is the first ever GCC pass that attempts to perform a specific part of automatic function multi-versioning (AFMV). Our pass will identify all the function clones that are the same and get rid of the duplicates.

How to accomplish this?

To achieve the outcomes listed above, we have to take a step back and really analyze what we are doing. Our GCC pass must analyze the functions that have been cloned. Upon identifying this, we need another function that can create a custom signature i.e. a hash and compare it with the signature of other functions. The key is though that our hash creation process must exclude factors like random variable names.

Phases of Stage 2

So how exactly are we going to tackle such a complex solution? We will do it in phases. Below are the phases I will complete to achieve the outcomes listed above.

  1. Create a new boiler plate gcc pass and add it into our gcc source directory.

    • We will create a new GCC pass and add it into our source directory.
  2. Identify the cloned functions

    • Our pass must detect the functions whose names follow the function.variant format and find its resolver function as well. This tells us whether a function has been cloned. NOTE: We will assume there is only one cloned function per program and that there are 2 versions of it.
  3. Compare the cloned functions → Creating a hash or compare each statement of each function

  4. Output the diagnostic message & test on both systems

    • After we compare the functions, the pass must output whether the function should be PRUNED or NOTPRUNED

    • Although our gcc pass will be created on the AArch64 platform, we need to ensure our pass works on the x86 architecture as well.

References

Credit for project stage 2 instructions goes to Professor Chris Tyler. Please visit his wiki to learn more at: http://spo600.cdot.systems/doku.php?id=spo600:2025_winter_project#project_stage_2clone-pruning_analysis_pass

0
Subscribe to my newsletter

Read articles from Hamza Teli directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hamza Teli
Hamza Teli