Posts

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 =

Building GCC from Source: A Journey into Compiler Construction (Project Stage 1)

Introduction: Building a compiler from source code is an informative yet intricate process that provides insights into the heart of programming languages and system architectures. In this blog post, I'll share my experience building the GNU Compiler Collection (GCC) on both an x86_64 system and an AArch64 system, highlighting the steps, time considerations, the impact of parallel building, and ultimately, how I confirmed the functionality of the newly built compiler. Building on x86_64 System: Step 1: Cloning the GCC Repository The journey began by cloning the GCC repository from the official Git repository: git clone git://gcc.gnu.org/git/gcc.git Step 2: Creating a Build Directory To maintain a clean separation between the source and build files, I created a dedicated build directory outside the source tree: mkdir build_x86_64 cd build_x86_64 Step 3: Configuring t

Lab 3 - Understanding arithmetic/math and strings in 6502 assembly language(SPO600)

Introduction As a beginner delving into the world of assembly language programming, I recently had the opportunity to explore the realms of the 6502 Jumps, Branches, and Procedural Math (including Bitwise Operations). In Lab 3, I got the learning opportunity to work with 6502 Math and String in order to develop and understand how we can utilize user interaction to receive our desired output. My quest led me to a captivating code adventure - a color selector with live updates. This blog chronicles my journey, highlighting the code's working functionality, critical elements, and my reflections on the experience. The Actual Code Block The code begins with a warm welcome, invoking the SCINIT routine to initialize and clear the screen, setting the stage for the colorful escapade. A delightful list of color names is then printed, each ready to be chosen by the user.   ; Colour selector - live updates ; ROM routine entry points define                    SCINIT