0

我已经编译了我的应用程序,但它未对齐 .bss 部分中的对象。为了比较建议,我在 CppUTest 框架内构建了相同的代码,使用相同的工具链,它显示填充在我的应用程序未对齐的同一位置。

应用地图文件(错位):

.bss            0x000132a0       0x3c
 *(.dynbss)
 .dynbss        0x000132a0        0x4 /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crti.o
                0x000132a0                stdout@@GLIBC_2.4
 *(.bss .bss.* .gnu.linkonce.b.*)
 .bss           0x000132a4        0x0 /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crt1.o
 .bss           0x000132a4        0x0 /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crti.o
 .bss           0x000132a4        0x1 /home/fanl/re8kkernel/tools/linux-devkit/bin/../lib/gcc/arm-arago-linux-gnueabi/4.3.3/crtbegin.o

####(MISSALIGN)####
 .bss           0x000132a5        0x0 obj_tgt/main.o

 .bss           0x000132a5        0x0 ../../common/lib/libhal-tgt.a(hal_app.o)
 .bss           0x000132a5        0x0 ../../common/lib/libhal-tgt.a(helper.o)
 .bss           0x000132a5        0x0 ../../common/lib/libhal-tgt.a(requirer.o)
 .bss           0x000132a5        0x0 ../../common/lib/libchelper-tgt.a(log.o)
 .bss           0x000132a5        0x0 ../../common/lib/libchelper-tgt.a(number.o)

CppUTest 框架编译(无错位)

.bss            0x00020230     0x3190
 *(.dynbss)
 .dynbss        0x00020230       0x9c /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crti.o
                0x00020230                _ZTVSt9exception@@GLIBCXX_3.4
                0x00020248                _ZTVN10__cxxabiv117__class_type_infoE@@CXXABI_1.3
                0x00020278                _ZTVSt9bad_alloc@@GLIBCXX_3.4
                0x00020290                _ZTVN10__cxxabiv120__si_class_type_infoE@@CXXABI_1.3
                0x000202bc                stdout@@GLIBC_2.4
                0x000202c0                _ZTISt9bad_alloc@@GLIBCXX_3.4
 *(.bss .bss.* .gnu.linkonce.b.*)
 .bss           0x000202cc        0x0 /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crt1.o
 .bss           0x000202cc        0x0 /home/fanl/re8kkernel/tools/linux-devkit/bin/../arm-arago-linux-gnueabi/usr/lib/crti.o
 .bss           0x000202cc        0x1 /home/fanl/re8kkernel/tools/linux-devkit/bin/../lib/gcc/arm-arago-linux-gnueabi/4.3.3/crtbegin.o

####(FILL HERE! NO MISSALIGN! I NEED THIS FILL TOO)####
 *fill*         0x000202cd        0x3 00

 .bss           0x000202d0        0x4 obj_tgt_test/test/mocks/call_counter.o
 .bss           0x000202d4       0x28 obj_tgt_test/test/mocks/terminal_intercepter.o
                0x000202d4                intercepted_output
 .bss           0x000202fc        0x0 obj_tgt_test/test/test_main.o

下面,我展示了用于在 CppUTest 框架上编译的标志:

OS Linux
Compile C and C++ source with CPPFLAGS:
  -I
  ../../common/CppUTest/include/
  -Isrc
  -g
  -I
  ../../common/include
  -D
  AUTO_GEN_BUILD_TAG='0-g1db06ad'
  -D
  AUTO_GEN_FIRWMARE_VERSION='0.00-re8k-app-2013-09-16'
  -D
  SYSTEM_UNIT_TEST
  -DCPPUTEST_COMPILATION
  -Iinclude/CppUTestExt/CppUTestGMock
  -Iinclude/CppUTestExt/CppUTestGTest
  -Wall
  -include
  ../../common/CppUTest/include/CppUTest/MemoryLeakDetectorMallocMacros.h

Compile C++ source with CXXFLAGS:
  -g
  -Wall
  -include
  ../../common/CppUTest/include/CppUTest/MemoryLeakDetectorNewMacros.h

Compile C source with CFLAGS:
  -Wextra
  -pedantic
  -Wstrict-prototypes
  -g

Link with LDFLAGS:
  -Wl,-Map=app-tgt-test.map
  -g

Link with LD_LIBRARIES:
  ../../common/lib/libhal-tgt-test.a
  ../../common/lib/libchelper-tgt-test.a
  -L
  ../../common/shared-lib/
  -lzmq
  -lrt
  -lpthread
  -lm
  -lrt
  -lpthread
  -lm
  -lstdc++

Create libraries with ARFLAGS:
  rv

最后,这是生成未对齐可执行文件的构建步骤:

arm-arago-linux-gnueabi-gcc -I. -Isrc -g -I ../../common/include -D AUTO_GEN_BUILD_TAG='"0-g1db06ad"' -D AUTO_GEN_FIRWMARE_VERSION='"0.00-re8k-app-2013-09-16"'  -Wall src/main.c -c -o obj_tgt/main.o

arm-arago-linux-gnueabi-gcc  obj_tgt/main.o ../../common/lib/libhal-tgt.a ../../common/lib/libchelper-tgt.a -L ../../common/shared-lib/ -lzmq -lrt -lpthread -lm   -o app-tgt -Wl,-Map=app-tgt.map

请,欢迎任何帮助。我需要从我的代码中删除这种错位。

4

0 回答 0