Hello, ld version 2.22 gives wrong symbol values for some symbols. To be precise, it seems to compute the right value for the symbol, but uses a bad value when the symbol is used. Here are some relevant parts of the map file: # Here, the value for iSegCode0 is correctly computed 0x0000000000000008 iSegCode0 = (ABSOLUTE (.) - ABSOLUTE (tabGDT)) # Later, the value is not used correctly 0x0000000000117002 0x2 SHORT 0x113008 iSegCode0 # With ld version 2.20, the correct value is used: 0x0000000000117002 0x2 SHORT 0x8 iSegCode0 For another symbol, I have: 0x0000000000000020 offset_master_PIC = ((ABSOLUTE (.) - ABSOLUTE (tabIDT)) >> 0x3) And if I link an assembly file that uses this symbol (it does a movb $offset_master_PIC, %al), I get this error: (.text+0x7): relocation truncated to fit: R_386_8 against symbol If I change my assembly file to do (movw $offset_master_PIC, %eax) instead and use objdump, I can see that offset_master_PIC has a completely wrong value (which explains the truncation error). Somehow it seems that the value of the symbol gets overwritten. We tried using valgrind to see if it was a simple memory error without success. We can reproduce the error in the complete projet; when trying to create a simpler case, we did not manage to reproduce the error. We tried to simplify our linker script, but with simple modifications (e.g. changing the order of sections) the error did not occur. The error already appeared with ld version 21.51.
> iSegCode0 = (ABSOLUTE (.) - ABSOLUTE (tabGDT)) > offset_master_PIC = ((ABSOLUTE (.) - ABSOLUTE (tabIDT)) >> 0x3) Did the above expressions occur inside output section statements in your linker script? If so, your symbols iSegCode0 and offset_master_PIC will be section relative since the right hand side of these expressions evaluate to a number. (See ld.info node "Expression Section".) When you use these symbols in relocations, they will have the output section address added to their (offset) value.
BTW, ld script expression rules changed between 2.20 and 2.21 so this would explain your problem completely. The old "rules" were so inconsistent that it was almost impossible to describe how ld evaluated script expressions.
No reply to questions. Assuming linker scripts modified to suit new ld evaluation.