#114 (wrong address computation with x86 elf pic) – The Yasm Modular Assembler Project

Ticket #114 (closed defect: fixed)

Opened 22 months ago

Last modified 22 months ago

wrong address computation with x86 elf pic

Reported by: Loren Merritt Owned by:
Priority: P1 Milestone:
Component: Object Format: elf Version: 0.6.0
Severity: normal Keywords:
Cc:

Description

yasm fails to generate position independent code. nasm on the same input works. In particular, "wrt ..gotpc" produces different offsets.

# yasm -f elf pic.asm -o pic.o
# gcc pic.o -o pic
# objdump -d pic | perl -ne 'print if /<main>/ .. /ret/'
08048340 <main>:
 8048340:       53                      push   ebx
 8048341:       e8 00 00 00 00          call   8048346 <main+0x6>
 8048346:       5b                      pop    ebx
 8048347:       81 c3 a9 11 00 00       add    ebx,0x11a9
 804834d:       8b 83 18 ef ff ff       mov    eax,[ebx-0x10e8]
 8048353:       8b 00                   mov    eax,[eax]
 8048355:       5b                      pop    ebx
 8048356:       c3                      ret    
# ./pic
Segmentation fault
# nasm -f elf pic.asm -o pic.o
# gcc pic.o -o pic
# objdump -d pic | perl -ne 'print if /<main>/ .. /ret/'
08048340 <main>:
 8048340:       53                      push   ebx
 8048341:       e8 00 00 00 00          call   8048346 <main.getgot>

08048346 <main.getgot>:
 8048346:       5b                      pop    ebx
 8048347:       81 c3 b2 11 00 00       add    ebx,0x11b2
 804834d:       8b 83 18 ef ff ff       mov    eax,[ebx-0x10e8]
 8048353:       8b 00                   mov    eax,[eax]
 8048355:       5b                      pop    ebx
 8048356:       c3                      ret    
# ./pic
#

Attachments

pic.asm (299 bytes) - added by Loren Merritt 22 months ago.
minimal testcase

Change History

Changed 22 months ago by Loren Merritt

minimal testcase

comment:1 Changed 22 months ago by peter

  • status changed from new to closed
  • resolution set to fixed

(In [1952]) Fix #114: Incorrect ELF32 ..gotpc address calculation. Reported by: Loren Merritt Fix by: mu@

We already had a testcase for this, but it had an incorrect "golden" result.

comment:2 Changed 22 months ago by peter

(In [1976]) Merge [1937] - [1960] (inclusive) from trunk. Notable user-visible changes: - Fixes in CPU features [1952] Fix #114: Incorrect ELF32 ..gotpc address calculation [1953] SSE5 support [1954] IEEE-754r "half precision" (16-bit) float support

Add/Change #114 (wrong address computation with x86 elf pic)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.