GNU binutils (ld linker, objdump, readelf, strip)

GNU Binary Utilities

Dependencies

GNU Binutils
Binary File Descriptor library (BFD)
Instruction Set Architecture (ISA)

Object File Format (executable files, object code, shared libraries, and core dumps)

Deutsch

a.out
ELF
COFF
Fat Binary
Universal Binary

English

An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. In addition to the object code itself, object files may contain metadata used for linking or debugging, including: information to resolve symbolic cross-references between different modules, relocation information, stack unwinding information, comments, program symbols, debugging or profiling information.

Executable
Object file
a.out
ELF
COFF
Mach-O

Debugging formats

GNU Debugger
Debugging formats DWARF and STAB
DWARF
stabs

Target Selection

Target Selection

$ objdump.exe -i
$ objdump.exe -H
supported targets (object file format):
pe-x86-64
pei-x86-64
pe-bigobj-x86-64
elf64-x86-64
elf64-l1om
elf64-k1om
pe-i386
pei-i386
elf32-i386
elf32-iamcu
elf64-little
elf64-big
elf32-little
elf32-big
plugin
srec
symbolsrec
verilog
tekhex
binary
ihex

supported architectures:
i386
i386:x86-64
i386:x64-32
i8086
i386:intel
i386:x86-64:intel
i386:x64-32:intel
i386:nacl
i386:x86-64:nacl
i386:x64-32:nacl
iamcu
iamcu:intel
l1om
l1om:intel
k1om
k1om:intel
plugin


$ arm-none-eabi-objdump.exe -i
$ arm-none-eabi-objdump.exe -H
supported targets (object file format):
elf32-littlearm
elf32-bigarm
elf32-little
elf32-big
plugin
srec
symbolsrec
verilog
tekhex
binary
ihex

supported architectures:
arm
armv2
armv2a
armv3
armv3m
armv4
armv4t
armv5
armv5t
armv5te
xscale
ep9312
iwmmxt
iwmmxt2
arm_any
plugin

ld

Option Purpose
-b input-format
--format=input-format
What input format is used. You may want to use this option if you are linking files with an unusual binary format. You can also use -b to switch formats explicitly. You can list the available binary formats with objdump -i
-r
--relocatable
Generate relocatable output—i.e., generate an output file that can in turn serve as input to ld. This is often called partial linking.
This option does the same thing as -i.
-i Perform an incremental link (same as option -r).
-o output
--output=output
Use output as the name for the program produced by ld; if this option is not specified, the name a.out is used by default.
-T scriptfile
--script=scriptfile
Use scriptfile as the linker script. This script replaces ld‘s default linker script (rather than adding to it), so commandfile must specify everything necessary to describe the output file. If scriptfile does not exist in the current directory, ld looks for it in the directories specified by any preceding -L options. Multiple -T options accumulate.

Linker Script

LD
LD: Linker Scripts
Linker Scripts
Linker Scripts

Red Hat Enterprise Linux 4: Using ld, the Gnu Linker – Linker Scripts

Chapter 4. Linker Scripts
4.2. Linker Script Format
4.3. Simple Linker Script Example
4.4. Simple Linker Script Commands
4.5. Assigning Values to Symbols
4.6. SECTIONS Command
4.7. MEMORY Command
4.8. PHDRS Command
4.9. VERSION Command
4.10. Expressions in Linker Scripts
4.11. Implicit Linker Scripts

objdump – displays information about one or more object files

man objdump

Linux Objdump Command Examples (Disassemble a Binary File)

objcopy – copies the contents of an object file to another

man objcopy

Option Purpose
-I bfdname
--input-target=bfdname
Consider the source file’s object format to be bfdname, rather than attempting to deduce (herleiten/rückschliessen) it.
-O bfdname
--output-target=bfdname
Write the output file using the object format bfdname.
-B bfdarch
--binary-architecture=bfdarch
Useful when transforming a architecture-less input file into an object file. In this case the output architecture can be set to bfdarch.
--rename-section oldname=newname[,flags] Rename a section from oldname to newname, optionally changing the section’s flags to flags in the process.
This option is particularly helpful when the input format is binary, since this will always create a section called .data. If for example, you wanted instead to create a section called .rodata containing binary data you could use a command line to achieve it.
objcopy              \
-I binary            \
-O <output_format>   \
-B <architecture>    \
--rename-section .data=.rodata,alloc,load,readonly,data,contents \
<input_binary_file>  \
<output_object_file>

nm – list symbols from object file

man nm

Example Scripts

bin2elf.sh

#!/bin/sh
# Convert a raw binary image into an ELF file suitable for loading into a disassembler

cat > raw$$.ld <<EOF
SECTIONS
{
EOF

echo " . = $3;" >> raw$$.ld

cat >> raw$$.ld <<EOF
  .text : { *(.text) }
}
EOF

CROSS_PREFIX=arm-none-eabi-

${CROSS_PREFIX}ld -b binary -r -o raw$$.elf $1
${CROSS_PREFIX}objcopy  --rename-section .data=.text \
                        --set-section-flags .data=alloc,code,load raw$$.elf
${CROSS_PREFIX}ld raw$$.elf -T raw$$.ld -o $2
${CROSS_PREFIX}strip -s $2

rm -rf raw$$.elf raw$$.ld

RFID Reader RC522

Datasheets

MFRC522 – Standard 3V MIFARE reader solution

eBay

alice1101983

Mifare RC522 Card Read Antenna RF Module RFID Reader IC Card Proximity Module

Shipping List:

  • 1x RFID-RC522 module
  • 1x standard S50 blank card
  • 1x S50 special-shaped card a (as shown by the key ring shape)
  • 1x straight, curved rows of pin of the article

Tutorials & Code

5Euro RFID/NFC Modul RC522 zum Auslesen von Mifare Tags
knksmith57/eecs373-actel-mfrc522-spi/mfrc522.c
MFRC-522 Rfid Reader Library for Raspberry PI
MFRC-522 Rfid Reader Library for Raspberry PI: Driver/MF522.c
MFRC522 and Arduino
How to get started with the Mifare MF522-AN and Arduino
Ti Tiva C / Stellaris Launchpad
github: stehgold/rc522 – Interfacing MFRC522 with Tiva/Stellaris LP

mikrocontroller.net

Forum

MF-RC522 und Antennenanpassung
Mifare Leser
Daten austausch über RFID
RFID Tierchip auslesen für Katzenklappe

Energia

SPI pin map for Stellaris Launchpad (LM4F120)
Two SPI modules

Optical Character Recognition (OCR)

OCR Software

tesseract-ocr
enfocus PitStop Pro
Foxit PhantomPDF™ Business 6.2
SmartSoft OCR Software
CVISION PDF Images to Text OCR
CVISION Font Recognition Software
CVISION pdf compressor

Articles

Better PDF OCR. ClearScan is smaller, looks better
Better PDF OCR: ClearScan is smaller, looks better

Forum

Acrobat Tips
How can I identify fonts from an image?
How To Recognize A Font?

VoIP

SNOM 300

FAQ

How can I enable multiple language support for snom300
How can I set the phone back to admin mode or factory defaults respectively
Firmware/Update/TFTP Update

XML Konfiguration

Configuration Files
Configuration Files/XML
Mass Deployment V7 (PDF)

update_policy
firmware_status
firmware_interval
admin_mode
admin_mode_password
http_user
http_pass

Grandstream Networks, Inc.

Grandstream HandyTone 486 ATA

Grandstream HandyTone 702 ATA

Grandstream HT701/HT702/HT704 Analog Telephone Adaptor (PDF)

Authentisierung Authentifizierung Autorisierung

  • Identifizierung
  • Verifizierung
  • Authentisierung
  • Authentifizierung
  • Autorisierung

Bei fast allen informationsverarbeitenden Systemen ist eine Identifizierung und Authentifizierung Vorraussetzung für die Autorisierung des Zugriffs auf Daten und Funktionen. Da alle drei Begriffe im Sprachgebrauch häufig synonym verwendet werden, sollen die Vorgänge und Begrifflichkeiten hier einmal abgegrenzt und erklärt werden:

Szenario: A möchte Zugriff auf eine Ressource, die durch Instanz B geschützt wird. A und B können dabei jeweils Personen oder Informationssysteme sein.
Identifizierung: A informiert B über seine Identität
Authentisierung: A übergibt Informationen, die eine Verifizierung seiner Identität durch B erlauben
Authentifizierung: B üerprüft, ob die vorgegebene Identität durch die Authentisierungsdaten bestätigt werden kann
Autorisierung: B läßt nach erfolgreicher Authentifizierung den Zugriff auf angeforderte Ressource zu.

Socket Programming

General

IPv6 Network Programming
Listen for and accept TCP connections in C
Sockets-based Communication Using IPv6
Linux IPv6 HOWTO (en)
Programming using C-API
Socket programming and the C BSD API
Protocol Independent Programming
Convert an IP address to a human-readable string in C

DNS

Using Google Public DNS (with IPv6)

ipv6.google.com

Beej’s Guide to Network Programming

9.7. gethostbyname(), gethostbyaddr()

Manual Pages

Wikipedia

getaddrinfo

linux.die.net

getaddrinfo(3)

man7.org

GETHOSTBYNAME(3)

Question & Statements

How to support both IPv4 and IPv6 connections
FreeBSD: Interesting facts about AI_ADDRCONFIG
Tell whether a text string is an IPv6 address or IPv4 address using standard C sockets API
How to determine if a string is a valid IPv6 address in C++?

Timeout

Linux: is there a read or recv from socket with timeout?
Socket with recv-timeout: What is wrong with this code?
Does recv(…) operate this way?

RFC

RFC 3493 – Basic Socket Interface Extensions for IPv6, February 2003
RFC 4038 – Application Aspects of IPv6 Transition, March 2005

Unix – Set/Rename Process Title

General

prctl – operations on a process

FreeBSD

setproctitle — set process title

Linux

About ELF Auxiliary Vectors
setproctitle()
linux: change the process’ name
procname

argv

procnamemodule.c
Howto change a UNIX process and child process name by modifying argv[0]
change process name without change argv[0] in Linux
Change process name in Linux
Giving a process a specific name in GNU/Linux?

Cross Debugging with GDB

FreeBSD under Linux

Build

i386fbsd-tdep.c:48:12: error: static declaration of ‘i386fbsd_sc_reg_offset’ follows non-static declaration
In file included from i386fbsd-tdep.c:26:0:
i386-tdep.h:228:12: note: previous declaration of ‘i386fbsd_sc_reg_offset’ was here
make[1]: *** [i386fbsd-tdep.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/usr/x86_64-freebsd/src/gdb-6.1.1/gdb'
make: *** [all-gdb] Error 2

# grep -r i386fbsd_sc_reg_offset .
./gdb/i386bsd-nat.c:#define SC_REG_OFFSET i386fbsd_sc_reg_offset
./gdb/i386fbsd-tdep.c:static int i386fbsd_sc_reg_offset[] =
./gdb/i386fbsd-tdep.c:  tdep->sc_reg_offset = i386fbsd_sc_reg_offset;
./gdb/i386fbsd-tdep.c:  tdep->sc_num_regs = ARRAY_SIZE (i386fbsd_sc_reg_offset);
./gdb/i386-tdep.h:extern int i386fbsd_sc_reg_offset[];

Execute

(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from apu/src/dns-amplification-defender/dnsdefend...Dwarf Error: Cannot handle DW_FORM_<unknown> in DWARF reader [in module /home/andreas/apu/src/dns-amplification-defender/dnsdefend]
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
0x000000080060c070 in ?? ()
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint

Receiving GDB error “Dwarf Error: Cannot handle DW_FORM_flag_present in DWARF reader [in module /xxx/yyy/executable]”

GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x000000080060c070 in ?? ()
(gdb) b dns_header_decode_label
Breakpoint 1 at 0x406bf4: file src/packet/dns_header.c, line 159.
(gdb) r
The "remote" target does not support "run".  Try "help target" or "continue".
(gdb) help target
Connect to a target machine or process.
The first argument is the type or protocol of the target machine.
Remaining arguments are interpreted by the target protocol.  For more
information on the arguments for a particular protocol, type
`help target ' followed by the protocol name.

List of target subcommands:

target bsd-uthreads -- BSD user-level threads
target core -- Use a core file as a target
target exec -- Use an executable file as a target
target extended-remote -- Use a remote computer via a serial line
target record -- Log program while executing and replay execution from log
target record-btrace -- Collect control-flow trace and provide the execution history
target record-core -- Log program while executing and replay execution from log
target record-full -- Log program while executing and replay execution from log
target remote -- Use a remote computer via a serial line
target tfile -- Use a trace file as a target

Type "help target" followed by target subcommand name for full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/
bin/     include/ lib/     usr/     
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) bt
#0  0x000000080060c070 in ?? ()
#1  0x0000000000000001 in ?? ()
#2  0x00007fffffffdd58 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) bt
#0  0x000000080060c070 in ?? ()
#1  0x0000000000000001 in ?? ()
#2  0x00007fffffffdd58 in ?? ()
#3  0x0000000000000000 in ?? ()
(gdb) c
Continuing.
warning: Could not load shared library symbols for /libexec/ld-elf.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Program received signal SIGBUS, Bus error.
0x0000000800949f8a in ?? () from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib/libc.so.7
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/lib
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
(gdb) c
Continuing.

Program terminated with signal SIGBUS, Bus error.
The program no longer exists.
(gdb) quit
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) ffile apu/src/dns-amplification-defender/dnsdefend
Undefined command: "ffile".  Try "help".
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x000000080060c070 in ?? ()
(gdb) c
Continuing.
warning: Could not load shared library symbols for 2 libraries, e.g. /lib/libc.so.7.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?

Program received signal SIGBUS, Bus error.
0x0000000800949f8a in ?? ()
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=x86_64-pc-freebsd10.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
No symbol table is loaded.  Use the "file" command.
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
(gdb) set sysroot /usr/x86_64-freebsd/x86_64-pc-freebsd10.0
(gdb) file apu/src/dns-amplification-defender/dnsdefend
Reading symbols from /home/andreas/apu/src/dns-amplification-defender/dnsdefend...done.
(gdb) target remote 10.41.10.20:2345
Remote debugging using 10.41.10.20:2345
Reading symbols from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1
0x000000080060c070 in ?? () from /usr/x86_64-freebsd/x86_64-pc-freebsd10.0/libexec/ld-elf.so.1
(gdb) b dns_header_decode_label
Breakpoint 1 at 0x406bf4: file src/packet/dns_header.c, line 159.
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000400c21 in _start ()
(gdb) bt
#0  0x0000000000400c21 in _start ()