I thought of using long jump to set the code segment register (CS). Getting into why I do this and why I do segmentation will take some time, so bear with me and consider this an academic exercise. I cannot get the syntax correctly.
Error: suffix or operands invalid for 'ljmp'
I know itβs stupid to put cs in a different register, but I decided that I would try, since using %0 does not work ( ax register does not work either).
I look at some code that compiles fine, and it drives me crazy, as I thought ljmp would be the same: __asm volatile ( "lcall $0x8, $far_call" );
Of course, I would welcome other hacker ways to influence the CS register.
void set_cs(u16 cs) { __asm__ volatile ( "mov %0, %%ax \n\t" "ljmp %%ax, $fake_label \n\t" "fake_label: \n\t" : : "r" (cs) : "ax" ); }
source share