Description of problem: The attached code returns different values with and without compilation optimization. $ gcc -Wall modify_ldt.c -o modify_ldt $ ./modify_ldt a = 42 a = 99 PASS $ gcc -Wall -O1 modify_ldt.c -o modify_ldt $ ./modify_ldt a = 42 a = 42 FAIL Version-Release number of selected component (if applicable): glibc-2.9-3.i686 gcc-4.3.2-7.i386 kernel-2.6.27.5-117.fc10.i686 How reproducible: always The code is based on Ulrich Drepper's test -- Make sure LDT is propagated correctly.
Created attachment 339169 [details] Test Program
The test code isn't correct. The compiler cannot look inside the asm statements in main() and see that they are really necessary. Based on the information given the compiler can drop some of them. Change all asms in main from asm(...) to asm volatile(...) and the code works fine.
Thanks Ulrich! I have fixed the test program, and it works fine indeed.