flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > ELF section header alignment

Author
Thread Post new topic Reply to topic
incertia



Joined: 21 Jun 2017
Posts: 2
incertia 21 Jun 2017, 18:41
With the rising popularity of the LLVM toolchain nowadays, I believe it would be beneficial to align data in a way that behaves nicely with with the LLVM linker. Most notably, LLVM will fail when e_shoff is not a multiple of two.
Code:
# fasm test.s test.o
flat assembler  version 1.71.60  (16384 kilobytes memory)
3 passes, 909 bytes.
# readelf -a test.o | grep -i 'start of section headers'
  Start of section headers:          525 (bytes into file)
# nm test.o
bfd plugin: LLVM gold plugin has failed to create LTO module: Invalid data was encountered while parsing the file
nm: test.o: no symbols
# ld.lld -o test test.o
ld.lld: error: invalid alignment of section headers
# vim test.s
# fasm test.s test.o
flat assembler  version 1.71.60  (16384 kilobytes memory)
3 passes, 910 bytes
# readelf -a test.o | grep -i 'start of section headers'
  Start of section headers:          526 (bytes into file)
# nm test.o
0000000000000000 T _start
# ld.lld -o test test.o
# exit    
Post 21 Jun 2017, 18:41
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 21 Jun 2017, 20:32
Even if not for the LLVM toolchain this would be a thing requiring correction, as it is a violation of ELF specification (which directly states that these fields need to be aligned). Thank you for pointing it out!

Would you be able to test this with the ELF formatting macros that come with fasmg? Because there I can fix it very quickly, while fixing it in fasm 1 core may take a bit longer.
Post 21 Jun 2017, 20:32
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 21 Jun 2017, 21:37
Anyway, I gave it a shot. Please try with 1.71.63 and see if the produced files are correct.
Post 21 Jun 2017, 21:37
View user's profile Send private message Visit poster's website Reply with quote
incertia



Joined: 21 Jun 2017
Posts: 2
incertia 22 Jun 2017, 17:45
Seems to be working. Thanks!
Post 22 Jun 2017, 17:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.