Tags 695547 +patch
Thanks

On 05/07/16 23:37, Steve McIntyre wrote:
So Peter and I were talking a little earlier on #debian-arm,
Specifically we were talking about the arm tag/flag stuff. I haven't looked into the powerpc issue. Freepascal has a chunk of platform/cpu specific assembler code that is used for mixed pascal/c programs to initialise both the freepascal runtime library and libc. The powerpc linux version of this file is located at rtl/linux/powerpc/cprt0.as . It would not surprise me if it was something to do with this init code.

It would be good to try and get a backtrace ("access violation" generally means that the freepascal runtime library trapped a segfault and turned it into an exception).

The remainder of this mail is about the arm tag/flag stuff.
  and he
was making good progress on fixing stuff. He may have stuff all done
shortly, I guess... :-)
I think i've fixed the arm tag/flag stuff. With the small patch attached I get the following.

root@odroidu2:/# readelf --file-header /usr/bin/fpc
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x100ec
  Start of program headers:          52 (bytes into file)
  Start of section headers:          410616 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         8
  Section header string table index: 7
root@odroidu2:/#

root@odroidu2:/# readelf -a /usr/bin/fpc
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x100ec
  Start of program headers:          52 (bytes into file)
  Start of section headers:          410616 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         4
  Size of section headers:           40 (bytes)
  Number of section headers:         8
  Section header string table index: 7


Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .note.ABI-tag     NOTE            000100c0 0000c0 000020 00   A  0   0 16
  [ 2] .text             PROGBITS        000100e0 0000e0 0501a4 00  AX  0   0  4
  [ 3] .rodata           PROGBITS        00060288 050288 010828 00   A  0   0  8
  [ 4] .data             PROGBITS        00081000 061000 003395 00  WA  0   0  8
  [ 5] .bss              NOBITS          00084398 064395 00237c 00  WA  0   0  4
  [ 6] .ARM.attributes   ARM_ATTRIBUTES  00000000 064395 000021 00      0   0  1
  [ 7] .shstrtab         STRTAB          00000000 0643b6 000042 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00010000 0x00010000 0x60ab0 0x60ab0 R E 0x10000
  LOAD           0x061000 0x00081000 0x00081000 0x03395 0x05714 RW  0x10000
  NOTE           0x0000c0 0x000100c0 0x000100c0 0x00020 0x00020 R   0x10
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x00000 RW  0x10

 Section to Segment mapping:
  Segment Sections...
   00     .note.ABI-tag .text .rodata
   01     .data .bss
   02     .note.ABI-tag
   03

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

No version information found in this file.

Displaying notes found at file offset 0x000000c0 with length 0x00000020:
  Owner                 Data size       Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
    OS: Linux, ABI: 2.0.0
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_VFP_args: VFP registers
root@odroidu2:/#

Which looks good to me, does it look ok to others here?

Some extracts from IRC for future reference.
<plugwash> does anyone know where I can find a decoder for .eabi_attribute statements ?
<--snip-->
* plugwash is trying to decipher the output of gcc -S but is struggling to find a list anywhere of what the numbers mean
<Sledge> ok...
<--snip-->
<Sledge> plugwash: I just tend to use readelf -A
<plugwash> what i'm trying to figure out is what I need to make fpc put in it's assembler files so the binaries come out tagged correctly
<Sledge> ack
<Sledge> I'm looking myself again, I added this stuff in binutils after all
<Sledge> but it's been a while
<Sledge> waiting on downloads ...
<--snip-->
<Sledge> plugwash: look at 3bfcb6528e6fb6a324b2e119f50f72a0674a1402 in git://sourceware.org/git/binutils-gdb.git for inspiration, maybe
* Sicelo009N (~sicelo@137.158.22.65) has joined #debian-arm
<Sledge> (unfortunately that's a few changes pushed together)
<plugwash> looks like the numbers are in elfcpp/arm.h in the binutils source
<Sledge> yup
<plugwash> one thing that is puzzling me, how do tags relate to flags?
<Sledge> tags are in the attributes section, and are basically a list
<Sledge> flags are specifically added in the ELF header to make them easier to work with
<Sledge> (not sure if that's what you're asking)
<plugwash> more what I was meaning is where do flags come from?
<Sledge> ah, ok
<plugwash> does the compiler have to set them explicitly? (and if so how?) does the linker turn tags into flags? something else?
<vagrantc> when one flag loves another flag...
<Sledge> vagrantc: :-)
<Sledge> plugwash: the compiler will set tags on various objects as it runs
<Sledge> the linker will check for the union of the tags and flags set and set flags appropriately on the output objects
<Sledge> elf32_arm_post_process_headers() is important here
<plugwash> right, so If I set the tags correctly binutils should set the flags correctly?
<plugwash> ok, it seems .o files have meaninful tags but not meaninful flags
* TiN (~t...@00018ff4.user.oftc.net) has joined #debian-arm
<plugwash> ok, just tested it looks like tags in the assembler file remain as tags in the .o file and are then converted to flags by the linker.
<Sledge> yup
<plugwash> i'm guessing the critical tag is Tag_ABI_VFP_args correct?
<plugwash> looks like it, removing that tag results in a change of flags
<Sledge> yeah
<Sledge> (sorry, just changed rooms here)
* Sicelo009N has quit (Read error: Connection reset by peer)
<plugwash> ok, now to try and insert that into freepascal
* Sicelo009N (~sicelo@137.158.22.65) has joined #debian-arm
<plugwash> i've just make a change to fpc which I hope will fix this, now for a testbuild
<Sledge> woo
<plugwash> btw one thing i've noticed about this issue is it only seems to affect "pure" pascal binaries, binaries that link against libc seem to pick up the tags from somewhere
<plugwash> I gtg
<Sledge> right
<Sledge> the things linking with libc will probably end up getting the right flags automatically by merging with the libc flags


diff -Nru fpc-3.0.0+dfsg/debian/changelog fpc-3.0.0+dfsg/debian/changelog
--- fpc-3.0.0+dfsg/debian/changelog     2016-06-02 19:43:38.000000000 +0000
+++ fpc-3.0.0+dfsg/debian/changelog     2016-07-05 13:14:03.000000000 +0000
@@ -1,3 +1,9 @@
+fpc (3.0.0+dfsg-7) unstable; urgency=medium
+
+  * Add elf tag to mark hardfp binaries as such. (Closes: 695547)
+
+ -- Peter Michael Green <plugw...@debian.org>  Tue, 05 Jul 2016 13:11:56 +0000
+
 fpc (3.0.0+dfsg-6) unstable; urgency=medium
 
   * Fix FTBFS due to wrong logic for latex files, we only need to ship
diff -Nru fpc-3.0.0+dfsg/debian/patches/armhf-tags.patch 
fpc-3.0.0+dfsg/debian/patches/armhf-tags.patch
--- fpc-3.0.0+dfsg/debian/patches/armhf-tags.patch      1970-01-01 
00:00:00.000000000 +0000
+++ fpc-3.0.0+dfsg/debian/patches/armhf-tags.patch      2016-07-05 
21:28:40.000000000 +0000
@@ -0,0 +1,16 @@
+Description: Add tags to make armhf binaries come out correctly.
+ Add elf tag to mark hardfp binaries as such. (Closes: 695547)
+Author: Peter Michael Green <plugw...@debian.org>
+Bug-Debian: https://bugs.debian.org/695547
+
+--- fpc-3.0.0+dfsg.orig/fpcsrc/compiler/arm/agarmgas.pas
++++ fpc-3.0.0+dfsg/fpcsrc/compiler/arm/agarmgas.pas
+@@ -135,6 +135,8 @@ unit agarmgas;
+         inherited WriteExtraHeader;
+         if TArmInstrWriter(InstrWriter).unified_syntax then
+           AsmWriteLn(#9'.syntax unified');
++        if target_info.abi = abi_eabihf then
++          AsmWriteLn(#9'.eabi_attribute 28, 1 @Tag_ABI_VFP_args');
+       end;
+ 
+ {****************************************************************************}
diff -Nru fpc-3.0.0+dfsg/debian/patches/series 
fpc-3.0.0+dfsg/debian/patches/series
--- fpc-3.0.0+dfsg/debian/patches/series        2016-06-01 19:45:01.000000000 
+0000
+++ fpc-3.0.0+dfsg/debian/patches/series        2016-07-05 21:27:47.000000000 
+0000
@@ -33,3 +33,4 @@
 Fixed-i386-case-jump-table-when-PIC-with-GOT-and-an-.patch
 Fixed-calling-of-external-procs-for-i386-non-darwin-.patch
 arm_UMULL_support_fix.patch
+armhf-tags.patch

Reply via email to