After I compile my own program, I want to filter out all relative addresses in the output file. I have already disassembled the output file into readable assembly code, but I'm rather new to assembly and have considered two ways of obtaining the location of all relative addresses:
Parse the assembly further by looking up each instruction and checking if it could contain a relative address. If it does, determine its location and so on.
Instruct the compiler to highlight the relative addresses, such as by inserting nops before and after each relative address. Then, parse the assembly by examining the positions of the nops.
The first option seemed difficult, because of the vast number of possible assembly instructions in x86 (x64/x32) and ARM made it potentially time-consuming and forgetting any case or misinterpreting any instruction could lead to errors.
I'm uncertain if the second option is realistically achievable or if it would involve less effort than the first one. I have never attempted to customize a compiler before, but I came across this way of adding nops before every function, though not before relative addresses.
Therefore, my questions are:
Is the second option realistically feasible? Are there any other approaches that I haven't considered?