Posts

Showing posts from December, 2023

Project Stage 2(Part 2) : Automatic IFUNC Capability and it's implementation within the GCC compiler

Introduction In the ever-evolving landscape of compiler technology, GCC (GNU Compiler Collection) remains a powerful and widely used tool. In this part of the project, we delve into the fascinating realm of automatic IFUNC (Indirect Function) capability, a feature that brings a new dimension of flexibility to GCC. What is IFUNC? IFUNC allows developers to defer the resolution of a function call until runtime. It's particularly useful when the appropriate implementation of a function depends on dynamic conditions. While manual IFUNC usage is common, automatic IFUNC capability adds a layer of automation, letting the compiler make decisions for us. Enabling Automatic IFUNC The first step in our journey is to understand how to enable automatic IFUNC capability during compilation. GCC introduces the '-fifunc' flag, signaling the compiler to harness the power of automatic IFUNC. Let's take a look at the command-line options: # Enable automatic IFUNC capability gcc -fifunc # ...

Exploring Automatic ifunc and Gimple Intermediate Representation in GCC (Project Stage 2 - Part 1)

Introduction In the world of compilers and optimization, understanding the intermediate representation of code is crucial. This blog post delves into the investigation of the proof-of-concept Automatic ifunc tool and the Gimple intermediate representation produced by the GCC compiler. We'll explore the steps involved, analyze the outputs, and discuss my key findings while working on this project. Part I: Automatic ifunc Tool Exploration Step 1: Obtaining the Proof-of-Concept Code The journey begins by obtaining the autoifunc proof-of-concept code from the specified file and unpacking it on an aarch64 machine. The provided commands guide the user through this process, resulting in a directory structure at ~/spo600/autoifunc-preprocessor-poc/. cd tar xvf /public/spo600-autoifunc-preprocessor-pos.tgz cd spo600/autoifunc-preprocessor-poc/ Step 2: Building and Comparing Outputs The "make" command is used to build the assembly language code. The subsequent diff command compare...

A Dive into Assembly Programming: AArch64 vs. x86_64 (LAB4)

Writing and debugging assembly code is a unique and challenging experience that offers a deep understanding of the underlying architecture of a computer system. In this blog post, I'll share my experiences with writing and debugging assembly code while completing the tasks for the lab 4, and drawing comparisons between the AArch64 and x86_64 architectures. Task 1: Hello World Loop Starting with a simple "Hello World" loop in both AArch64 and x86_64, we encountered the raw power of registers. The minimalistic yet powerful nature of assembly language became apparent as we directly manipulated registers, delving into the bare metal of the architecture. In AArch64, the mov, add, cmp, and b.ne instructions orchestrated the loop. Meanwhile, in x86_64, the dance of %rax, %rdi, and %rsi registers choreographed the elegant routine. Writing assembly code felt like composing a symphony of registers, each playing its part in harmony. For AArch64 Assembly :- .text .globl _start min = ...