代码之家  ›  专栏  ›  技术社区  ›  0xC0000022L

从没有可用源代码的旧的基于GCC的工具链进行更新

  •  1
  • 0xC0000022L  · 技术社区  · 5 年前

    旧的工具链配置如下:

    $ /opt/arm-2012.03/bin/arm-none-linux-gnueabi-gcc -v
    Using built-in specs.
    COLLECT_GCC=/opt/arm-2012.03/bin/arm-none-linux-gnueabi-gcc
    COLLECT_LTO_WRAPPER=/opt/arm-2012.03/bin/../libexec/gcc/arm-none-linux-gnueabi/4.6.3/lto-wrapper
    Target: arm-none-linux-gnueabi
    Configured with: /scratch/nsidwell/arm/linux/src/gcc-4.6-2012.03/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-arch=armv5te --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables} -D__CS_SOURCERYGXX_MAJ__=2012 -D__CS_SOURCERYGXX_MIN__=3 -D__CS_SOURCERYGXX_REV__=57 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --enable-shared --enable-lto --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion='Sourcery CodeBench Lite 2012.03-57' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/nsidwell/arm/linux/install/arm-none-linux-gnueabi/libc --with-gmp=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-mpc=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --with-libelf=/scratch/nsidwell/arm/linux/obj/host-libs-2012.03-57-arm-none-linux-gnueabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/nsidwell/arm/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/nsidwell/arm/linux/install/arm-none-linux-gnueabi/bin
    Thread model: posix
    gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-57)
    

    arm-linux-gnueabi-gcc (来自ubuntu18.04包) gcc-arm-linux-gnueabi ,版本 4:7.4.0-1ubuntu2.3 )来执行我的命令。

    SIGILL 运行包含“不兼容内容”的userland二进制文件时。(U型靴) mkimage 无论我使用新的还是旧的工具链来构建,所使用的二进制仍然是原始的,并且它的输出是相同的 vmlinux

    现在,到目前为止,我使用了以下两个标志,我确定旧的工具链使用了这两个标志,但是新的工具链有不同的默认值:

    -march=armv5te -mfix-cortex-m3-ldrd
    

    二进制文件只在少数几个方面有所不同,我认为其中存在着阻止内核启动的问题。

    通过 gcc -v -E - </dev/null

    另外,新的 readelf 包装 gcc arm linux gnueabi e_flags (ELF头标志)哪个 自述 呼叫“有入口点”,区别:

    -  Flags:                             0x5000002, has entry point, Version5 EABI
    +  Flags:                             0x5000002, Version5 EABI, <unknown>
    

    到目前为止,我找不到任何方法设置这面旗帜。

    当比较两个结果的属性时 文件中,差异较大,但似乎可以管理:

    $ diff <(/opt/arm-2012.03/bin/arm-none-linux-gnueabi-readelf -hA ../vmlinux-gcc-4) <(/opt/arm-2012.03/bin/arm-none-linux-gnueabi-readelf -hA ../vmlinux-gcc-7)
    --- /dev/fd/63  2019-09-25 16:25:22.056115611 +0200
    +++ /dev/fd/62  2019-09-25 16:25:22.056115611 +0200
    @@ -10,14 +10,14 @@
       Version:                           0x1
       Entry point address:               0xc0008000
       Start of program headers:          52 (bytes into file)
    -  Start of section headers:          3446116 (bytes into file)
    -  Flags:                             0x5000002, has entry point, Version5 EABI
    +  Start of section headers:          4919528 (bytes into file)
    +  Flags:                             0x5000200, Version5 EABI, <unknown>
       Size of this header:               52 (bytes)
       Size of program headers:           32 (bytes)
       Number of program headers:         3
       Size of section headers:           40 (bytes)
    -  Number of section headers:         26
    -  Section header string table index: 23
    +  Number of section headers:         27
    +  Section header string table index: 26
     Attribute Section: aeabi
     File Attributes
       Tag_CPU_name: "5TE"
    @@ -30,4 +30,3 @@
       Tag_ABI_FP_number_model: IEEE 754
       Tag_ABI_align_needed: 8-byte
       Tag_ABI_enum_size: int
    -  Tag_DIV_use: Not allowed
    

    关于节标题的差异可能不太相关,如果有的话。但最突出的是 e\ U标志 (从新旧文件中选取可读性最高的输出 ):

    -  Flags:                             0x5000002, has entry point, Version5 EABI
    +  Flags:                             0x5000200, Version5 EABI, soft-float ABI
    

    -  Tag_DIV_use: Not allowed
    

    我的目标是这个CPU(为了简洁起见,去掉了它):

    Processor       : ARM926EJ-S rev 5 (v5l)
    Features        : swp half thumb fastmult edsp java
    CPU architecture: 5TEJ
    CPU variant     : 0x0
    CPU part        : 0x926
    CPU revision    : 5
    Hardware        : DaVinci DA850/OMAP-L138/AM18x EVM
    

    综合比较 -Q --help=-target -march -mcpu

    • 旧的: arm-none-linux-gnueabi-gcc -Q --help=target
    • 新增: arm-linux-gnueabi-gcc -march=armv5tej -mcpu=arm926ej-s -Q --help=target

    Option                        old         new
    -falign-arrays                [disabled]  n/a
    -mabi=                        [empty]     aapcs-linux
    -mabort-on-noreturn           [disabled]  [disabled]
    -mandroid                     [disabled]  [disabled]
    -mapcs                        [disabled]  [disabled]
    -mapcs-float                  [disabled]  n/a
    -mapcs-frame                  [disabled]  [disabled]
    -mapcs-reentrant              [disabled]  [disabled]
    -mapcs-stack-check            [disabled]  [disabled]
    -march=                       armv5te     armv5tej
    -marm                         [enabled]   [enabled]
    -masm-syntax-unified          n/a         [disabled]
    -mbig-endian                  [disabled]  [disabled]
    -mbionic                      [disabled]  [disabled]
    -mcallee-super-interworking   [disabled]  [disabled]
    -mcaller-super-interworking   [disabled]  [disabled]
    -mcirrus-fix-invalid-insns    [disabled]  n/a
    -mcmse                        n/a         [disabled]
    -mcpu=                        [empty]     arm926ej-s
    -mfix-cortex-m3-ldrd          [enabled]   [disabled]
    -mflip-thumb                  n/a         [disabled]
    -mfloat-abi=                  [empty]     soft
    -mfp16-format=                [empty]     none
    -mfp=                         [empty]     n/a
    -mfpe                         [disabled]  n/a
    -mfpe=                        [empty]     n/a
    -mfpu=                        [empty]     vfp
    -mglibc                       [enabled]   [enabled]
    -mhard-float                  [disabled]  [empty]
    -mlittle-endian               [enabled]   [enabled]
    -mlong-calls                  [disabled]  [disabled]
    -mmusl                        n/a         [disabled]
    -mneon-for-64bits             n/a         [disabled]
    -mpic-data-is-text-relative   n/a         [enabled]
    -mpic-register=               [empty]     [empty]
    -mpoke-function-name          [disabled]  [disabled]
    -mprint-tune-info             n/a         [disabled]
    -mpure-code                   n/a         [disabled]
    -mrestrict-it                 n/a         [disabled]
    -msched-prolog                [enabled]   [enabled]
    -msingle-pic-base             [disabled]  [disabled]
    -mslow-flash-data             n/a         [empty]
    -msoft-float                  [disabled]  [empty]
    -mstructure-size-boundary=    [empty]     8
    -mthumb                       [disabled]  [disabled]
    -mthumb-interwork             [enabled]   [disabled]
    -mtls-dialect=                gnu         gnu
    -mtp=                         [empty]     soft
    -mtpcs-frame                  [disabled]  [disabled]
    -mtpcs-leaf-frame             [disabled]  [disabled]
    -mtune=                       [empty]     [default]
    -muclibc                      [disabled]  [disabled]
    -munaligned-access            [enabled]   [disabled]
    -mvectorize-with-neon-double  n/a         [disabled]
    -mvectorize-with-neon-quad    [disabled]  [enabled]
    -mword-relocations            [disabled]  [disabled]
    -mwords-little-endian         [disabled]  n/a
    

    问题

    如何强制现代(打包的)工具链

    1. Tag_DIV_use: Not allowed (==值1) 文件属性 确保编译器不会发出 sdiv udiv 说明书?

    注:我很高兴通过额外的链接器或汇编命令行选项 从一些潜在的伪操作码构建另一个对象文件,到目前为止我还没有找到这些伪操作码,但是它们产生了我需要的东西。 (一) 知道 怎么做,我都做过了-都是用 crosstool / crosstool-ng


    我在搜索binutils源代码方面取得了部分成功,并在测试套件中找到了以下代码行 gas

    .eabi_attribute Tag_DIV_use, 1
    

    我终于可以走私 Tag_DIV_use 属性添加到对象文件中。原来是那个场景 .eabi_attribute 对于 标签分区使用 ld 我不支持这些指令。不幸的是,单独设置属性似乎并不能阻止编译器发出这些指令。

    .S asm("...") 气体 '观点。可以通过检查define __ASSEMBLY__ 或者直接使用伪操作码 使用C编译器可以接受的语法。

    #ifdef __ASSEMBLY__ /* from inside .S files */
        .eabi_attribute Tag_DIV_use,1
    #else
        asm(".eabi_attribute Tag_DIV_use,1");
    #endif
    

    0 回复  |  直到 5 年前