top of page
Writer's picturearman valaee

Software Portability Project - Stage 1.1 Background

Updated: Nov 26, 2022

In the previous blogs, I discussed different aspects of software optimization.

Assembly language has an incredible and expanding world which requires a considerable commitment to learn and master the skill.

On the other hand, it has many benefits too. It can run much faster than any different language but the main problem is the developing difficulties.


At this point in my experience with assembly, I find it nearly impossible to develop complete software using assembly language for someone with my level of assembly knowledge. But this does not mean that I still can not benefit from my little knowledge and experience of this language, but how?

In-line Assembler is the answer to this question!


In this blog, I will explain the In-line Assembler, its problems, and the solution to those problems!



In-Line Assembler


In-line Assembler is a feature that let you use assembly language in a higher-level language. Or in other words, it will let you combine assembly with various languages.

For example, you can write a complete program using C and implement some commands from the assembly language.

Here is a simple example:



This will help programmers to implement assembly language in higher-level languages and use its benefits.

The biggest benefit of using assembly is the optimization and faster program runtime. This also applies to In-Line Assembler.

But some problems come with it!



What is the biggest problem with using In-Line Assembler?


Higher-level languages use a compiler to make the code readable to the system.

But as we learned in this course, different machines from different manufacturers will use different types of assembly language.

So we will not have a problem if we compile a high-level language using the compiler in any machine, because the compiler will do its job based on the machine's needs. But if we implement assembly language it will not compile that! We can implement the assembly lines based on our machine needs, but what if we want to use the same program in other machines as well? (This is usually the case.)


Considering SIMD operations, even machines from the same manufacturer may have different capabilities that would not run our program.

So the biggest problem of using In-Line Assembler is compatibility!

iFunc is the solution to this problem!



iFunc


Short for Indirect Function, is a feature that allows the developer to make various implementations of a function and select between them in the program runtime.

"iFunc symbols point to the resolver function and all calls to such functions are delayed until runtime." <sourceware, GNU_IFUNC>



Conclusion


In this project, we are going solve the problem that we discussed in this blog.

For the project scope, we will focus on developing the iFunc for a single function that only needs to run in AArch64 architecture.

But even in the same architecture we will need different implementations for ASIMD, SVE, and SVE2.

The main goal of this program is to solve this problem by creating the solution using iFunc.


You can view my plan for this project in the next blog.




11 views0 comments

Comments


bottom of page