GCC multilib

Compiler comes with different versions of the same library. This support is known as compiler multilib supports. The compiler will choose a specific version of the targeted library depending upon the compiler options used to build source code.

Let’s see how compiler manages this multilib support:

Find out compiler version

$ arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (Sourcery CodeBench 2015.12-159) 5.2.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

Find out supported multilibs

$ arm-none-linux-gnueabi-gcc -print-multi-lib
.;
armv4t;@march=armv4t
vfp;@mfloat-abi=softfp
be;@mbig-endian
vfp-be;@mfloat-abi=softfp@mbig-endian
armv7-a-neon;@march=armv7-a@mfloat-abi=softfp@mfpu=neon
armv7-a-hard;@march=armv7-a@mfloat-abi=hard@mfpu=neon
thumb2;@mthumb@march=armv7-a
thumb2-be;@mthumb@march=armv7-a@mbig-endian
thumb2-neon;@mthumb@march=armv7-a@mfloat-abi=softfp@mfpu=neon

Let’s take a single line of the information shown by the compiler to understand what’s going on
armv4t;@march=armv4t

Compiler will use libraries from the armv4t folder if source code is compiled using -march=armv4t.

armv7-a-hard;@march=armv7-a@mfloat-abi=hard@mfpu=neon

Compiler will use libraries from armv7-a-hard folder if source code is compiled using -march=armv7-a -mfloat-abi=hard -mfpu=neon.

You can also find out directory using another trick:

$ arm-none-linux-gnueabi-gcc -print-multi-directory -march=armv4t
armv4t

$ arm-none-linux-gnueabi-gcc -print-multi-directory -march=armv7-a -mfloat-abi=hard -mfpu=neon
armv7-a-hard

$ arm-none-linux-gnueabi-gcc --print-multi-directory -mthumb -march=armv7e-m -mfloat-abi=softfp -mfpu=vfpv3-d16
vfp

There are some options supported by GCC to play with multi-lib. https://gcc.gnu.org/onlinedocs/gccint/Target-Fragment.html (Look for MULTILIB_)

 

Mount disk (dd) image

If you want to see contents of the dd image of disk without actually executing dd command, use following trick.

$ fdisk -l sdcard-image.img

Disk sdcard-image.img: 7948 MB, 7948206080 bytes
255 heads, 63 sectors/track, 966 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x29c7ef50

      Device Boot  Start     End  Blocks Id System
sdcard-image.img1 * 2048  129023   63488  c W95 FAT32 (LBA)
sdcard-image.img2 129024 7744511 3807744 83 Linux

Make note of the values shown in the Start column. Let’s say we want to see partition #1, it is starting from 20148 so actually disk will start from 2048 x 512 =  1048576 as sector size is 512. Now we will use value 1048576 for mount command.

$ mkdir p1
$ mount -o ro,loop,offset=1048576 sdcard-image.img p1

p1 folder is having contents of p1.

For p2 use

$ mkdir p2
$ mount -o ro,loop,offset=66060288 sdcard-image.img p2

As 129024 x 512 = 66060288