GithubHelp home page GithubHelp logo

uclinux-dev / elf2flt Goto Github PK

View Code? Open in Web Editor NEW
74.0 20.0 41.0 425 KB

ELF to bFLT (binary flat) converter for no-mmu Linux targets

License: GNU General Public License v2.0

C 73.91% Shell 17.91% Makefile 2.84% M4 5.35%
uclinux elf binutils bflt

elf2flt's Introduction

elf2flt

Build Status

Copyright (C) 2001-2003, SnapGear (www.snapgear.com) David McCullough [email protected] Greg Ungerer [email protected]

This is Free Software, under the GNU Public License v2 or greater. See LICENSE.TXT for more details.

Elf2flt with PIC, ZFLAT and full reloc support. Currently supported targets include: m68k/ColdFire, ARM, Sparc, NEC v850, MicroBlaze, h8300, SuperH, and Blackfin.

Compiling

You need an appropriate libbfd.a and libiberty.a for your target to build this tool. They are normally part of the binutils package.

To compile elf2flt do:

./configure --target=<ARCH> --with-libbfd=<libbfd.a> --with-libiberty=<libiberty.a>
make
make install

The argument to configure specifies what the target architecture is. This should be the same target as you used to build the binutils and gcc cross development tools. The --with-libbfd and --with-libiberty arguments specify where the libbfd.a and libiberty.a library files are to use.

Files

  • README.md - this file
  • configure - autoconf configuration shell script
  • configure.ac - original autoconf file
  • config.* - autoconf support scripts
  • Makefile.in - Makefile template used by configure
  • elf2flt.c - the source
  • flthdr.c - flat header manipulation program
  • flat.h - header from uClinux kernel sources
  • elf2flt.ld - An example linker script that works for C/C++ and uClinux. ld-elf2flt processes this on the fly before passing it to the real linker to use (in place of the default linker script provided by the normal toolchain).
  • ld-elf2flt - A linker replacement that implements a -elf2flt option for the linker and runs elf2flt automatically for you. It auto detects PIC/non-PIC code and adjusts its option accordingly. It uses the environment variable FLTFLAGS when running elf2flt. It runs /.../-ld.real to do the actual linking.
  • stubs.c - Support for various functions that your OS might be missing (e.g. Windows-vs-Linux). Only used by our programs above -- it is not included in the flat/ELF programs we produce.

Tips

The ld-elf2flt produces 2 files as output. The binary flat file X, and X.gdb which is used for debugging and PIC purposes.

The -p option requires an elf executable linked at address 0. The elf2flt.ld provided will generate the correct format binary when linked with the real linker with no -r option for the linker.

The -r flag can be added to PIC builds to get contiguous code/data. This is good for loading application symbols into gdb (add-symbol-file XXX.gdb).

Support

You can use the github site to file issues and send pull requests, and the [email protected] mailing list to contact the developers.

elf2flt's People

Contributors

codewiz avatar damien-lemoal avatar erikbandersen avatar floatious avatar gregungerer avatar jcmvbkbc avatar jserv avatar kirillsmirnov avatar mcoquelin-stm32 avatar mpilawa avatar msteveb avatar regymm avatar romainnaour avatar stilor avatar tpetazzoni avatar vapier avatar wbx-github avatar ysat0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elf2flt's Issues

Input file contains no relocation info error

I have a simple c helloworld app:

#include <stdio.h>

int main() {
   printf("Hello World!");
   return 0;
}

and I've compiled it on ubuntu 20 using prebuilt arm toolchain:

$arm-linux-gnueabi-gcc -shared -fPIE -fPIC -mcpu=cortex-m3 helloworld.c -o out.o

that should create a FD-PIC elf. then I execute elf2flt:

$elf2flt out.o
    elf2flt: out.o: Input file contains no relocation info

what's wrong here?

Failed BINFMT_FLAT with uclinux tools-20030909

I'm compiling sash for an armnommu target. However, when i'm running it on the target, I got this error:

BINFMT_FLAT: bad magic/rev (0x0, need 0x4)

Does anyone know how to fix?

P.S. The flthdr output:

romfs/bin/sh                                                                                          Magic:        bFLT                                                                                Rev:          4                                                                                   Build Date:   Fri Dec 22 17:40:51 2023                                                            Entry:        0x50                                                                                Data Start:   0xc120                                                                              Data End:     0xd6a0                                                                              BSS End:      0xe450                                                                              Stack Size:   0x1000                                                                              Reloc Start:  0xd6a0
    Reloc Count:  0x322                                                                               Flags:        0x1 ( Load-to-Ram )

I have tried it with qemu-arm, but got the same error.

BFD_VMA_FMT is removed from bfd.h as of binutils 2.40

After adding binutils 2.40 to crosstool-ng we see the following build error

[EXTRA]    Building elf2flt
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:219:38: error: expected ')' before 'BFD_VMA_FMT'
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:455:56: error: expected ')' before 'BFD_VMA_FMT'
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:882:68: error: expected ')' before 'BFD_VMA_FMT'
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:901:68: error: expected ')' before 'BFD_VMA_FMT'
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:1589:65: error: expected ')' before 'BFD_VMA_FMT'
[ERROR]    /home/ctng/crosstool-ng/.build/armv6-nommu-linux-uclibcgnueabi/src/elf2flt/elf2flt.c:1609:65: error: expected ')' before 'BFD_VMA_FMT'

Looks like BFD_VMA_FMT is gone. It might be necessary to switch to PRIx64 instead (which is what gdb did).

Support for R_ARM_THM_MOVW_ABS_NC / R_ARM_THM_MOVT_ABS relocations?

When building some Buildroot packages for ARM Cortex-M (ARMv7-M), we sometimes see movt/movw instructions generated with corresponding R_ARM_THM_MOVW_ABS_NC and/or R_ARM_THM_MOVT_ABS relocations generated:

00000380  00003f2f R_ARM_THM_MOVW_AB 00000000   PawnHashKey
00000388  00003f30 R_ARM_THM_MOVT_AB 00000000   PawnHashKey
00000464  00003f2f R_ARM_THM_MOVW_AB 00000000   PawnHashKey
00000470  00003f30 R_ARM_THM_MOVT_AB 00000000   PawnHashKey

Unfortunately, these types of relocations are not handled by elf2flt, which errors out with:

ERROR: reloc type R_ARM_THM_MOVW_ABS_NC unsupported in this context
ERROR: reloc type R_ARM_THM_MOVT_ABS unsupported in this context
ERROR: reloc type R_ARM_THM_MOVW_ABS_NC unsupported in this context
ERROR: reloc type R_ARM_THM_MOVT_ABS unsupported in this context

Would it be possible to add support for these relocation types ?

.ARM.exidx RO data section is incorrectly mapped to data

Hi,

Starting with Binutils 2.33.1, elf2flt segfault while building busybox:
"ld (ld-elf2flt):
/builds/kubu93/toolchains-builder/build/opt/armv7m--uclibc--bleeding-edge-2/arm-buildroot-uclinux-uclibcgnueabi/bin/elf2flt

This was reported to the Binutils mailing list and it's seems an elf2flt issue with .ARM.exidx RO data section as explained by :
https://sourceware.org/ml/binutils/2019-10/msg00132.html

Can you have a look ?

Best regards,
Romain

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.