Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2012-06

x86_64 case jumptables should work

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Matthias K.

Hi,

After playing around with the jumptable generation for x86_64 (Linux) --> x86/nx86set.pas, i couldn't reproduce bug #0011931 anymore.

Before someone else reiterates the building/testing/elf dumping, i'll describe shortly what i've found.

The code generation for jumptables didn't change since #0011931, so i've inspected the data sections generated. For a simple testlibrary, the library code/data itself was correct but the pulled in rtl code/data wasn't (see Appendix1 / Appendix 2).
The jumptable indices point to the section start which result in unexpected behavior on branch.

After "elf/obj dumping around" a bit and bisecting, i've hit the corresponding commit, which fixes x86_64 addend calculation for these reloc types, svn commit 17556 (or 17580), which refers to #19416 about const pointers (and the jumptable is a const pointer collection ;) )

Can someone verify it (probably also for other target OS using x86_64) and then re-enable jumptables for trunk (and back-port to fixes 2.6)?

Regards,
Matthias

Appendix1 system.o:
-----------------

svn 17555; system.o; data.rel bits

Relocation section '.rela.data.rel' at offset 0x5546c contains 799 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000200000001 R_X86_64_64 0000000000000000 .text + 0 000000000008 000200000001 R_X86_64_64 0000000000000000 .text + 0 ...

which is a wrong (on relocation, R_X86_64_64 is relocated SECTION/SYMBOL + ADDEND) and

svn 17556; system.o; data.rel bits

Relocation section '.rela.data.rel' at offset 0xaa468 contains 799 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000200000001 R_X86_64_64 0000000000000000 .text + ae5 000000000008 000200000001 R_X86_64_64 0000000000000000 .text + b15 ...

with correct addend.

-----------------

Appendix2 some testlibrary

-----------------

pre svn 17555: jumptable (or const ptr's) relocation entries

Offset Type Value
...
0000000000226df8 R_X86_64_RELATIVE *ABS*+0x00000000002270f0 # -> 2270f0
...
00000000002270f0 R_X86_64_RELATIVE *ABS*+0x0000000000006650 # idx 0 -> "section base"
00000000002270f8 R_X86_64_RELATIVE *ABS*+0x0000000000006650 # idx 1 -> "section base"
0000000000227100 R_X86_64_RELATIVE *ABS*+0x0000000000006650 # idx 2 -> "section base"
...

svn 17556+: jumptable (or const ptr's) relocation entries

...
0000000000227df0 R_X86_64_RELATIVE *ABS*+0x00000000002280f0 # -> 2280f0
...
00000000002280f0 R_X86_64_RELATIVE *ABS*+0x0000000000007125 # idx 0 -> caseblock 1
00000000002280f8 R_X86_64_RELATIVE *ABS*+0x0000000000007155 # idx 1 -> caseblock 2 (actualy, caseblock 5 or so)
0000000000228100 R_X86_64_RELATIVE *ABS*+0x000000000000713d # idx 2 -> caseblock 3
0000000000228108 R_X86_64_RELATIVE *ABS*+0x000000000000713d # idx 3 -> caseblock 3
...

-----------------

Reply by email