Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - QNX 7 Memory Model / Compiler Question: (4 Items)
   
QNX 7 Memory Model / Compiler Question  
Hi,

We are using the 32 bit memory model of QNX 7 (relevant build file info)
[virtual=x86,bios +compress] boot = {
	startup-x86 -v
	PATH=/sbin:/usr/sbin:/bin:/usr/bin:/proc/boot:/x86/sbin:/x86/usr/sbin:/x86/bin:/x86/usr/bin LD_LIBRARY_PATH=/proc/boot:
/lib:/usr/lib:/lib/dll:/lib/dll/pci:/x86/lib:/x86/usr/lib:/x86/lib/dll procnto-smp-instr -v
}

We are porting over an existing code base from 6.32 that works using gcc 3.3.5. I've changed my Makefiles to use 5.5.4,
gcc_ntox86 so that my compile and link lines look as follows:

Building main/src
make[1]: Entering directory 'C:/Users/Admin/ide-7.0-workspace/MainlineSource/Controller/main/src'
qcc -V5.4.0,gcc_ntox86    -lang-c++ -D_PTHREADS=1 -g -w9 -Wall -Werror -Wno-deprecated -M -I../../../ThirdPartyLibs/POCO
/include -I../../../ThirdPartyLibs/expat-2.2.4/include -I../../../SystemCore/CommonOS/src  -I../../../SystemCore/Core/
src  -I../../../Controls/src  -I../../../HardwareManagers/EthernetIOMgr/src  -I../../../HardwareManagers/NativeIOMgr/src
  -I../../../HardwareManagers/LMBoardMgr/src  -I../../../Specials/src  -I../../../HardwareManagers/DeviceMgr/src  -c 
deviceMgr.cpp -o ../obj/debug/deviceMgr.o

Linking specialsMgr
qcc -V5.4.0,gcc_ntox86 -E -lang-c++ -D_PTHREADS=1 -g -w9 -Wall -Werror -Wno-deprecated -M -I../../../ThirdPartyLibs/POCO
/include -I../../../ThirdPartyLibs/expat-2.2.4/include -I../../../SystemCore/CommonOS/src  -I../../../SystemCore/Core/
src  -I../../../Controls/src  -I../../../HardwareManagers/EthernetIOMgr/src  -I../../../HardwareManagers/NativeIOMgr/src
  -I../../../HardwareManagers/LMBoardMgr/src  -I../../../Specials/src  -I../../../HardwareManagers/DeviceMgr/src  -Wp,-
MM,-MP,-MT,../obj/debug/../obj/debug/deviceMgr.o deviceMgr.cpp > ../obj/debug/deviceMgr.d
qcc -V5.4.0,gcc_ntox86 -lang-c++ -g -M -D_PTHREADS=1 -l m ../obj/debug/deviceMgr.o -Wl,--start-group,../../../Controller
/main/libs/debug/core.a,../../../Controller/main/libs/debug/commonOS.a,../../../Controller/main/libs/debug/devices.a,--
end-group -Wl,--start-group,../../../ThirdPartyLibs/POCO/libs/libPocoNetd.a,../../../ThirdPartyLibs/POCO/libs/
libPocoFoundationd.a,../../../ThirdPartyLibs/POCO/libs/libPocoUtild.a,../../../ThirdPartyLibs/POCO/libs/libPocoJSONd.a,-
-end-group -lsocket -lexpat -o ../obj/debug/deviceMgr

My understanding is this is building 32 bit binaries.

However when our executables run they all crash quite quickly and always doing a memset() command. If I capture a core 
file from one of the crashes I see (not sure why I get the libc.so.4 mismatch)

C:\Users\Admin\ide-7.0-workspace\MainlineSource\Controller\main\bin\debug>ntox86-gdb specialsMgr specialsMgr.core
GNU gdb (GDB) 7.12 [qnx700 r1234]
Copyright (C) 2016 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-w64-mingw32 --target=i586-pc-nto-qnx7.0.0".
Type "show configuration" for configuration details.Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from specialsMgr...done.
[New pid 4010029 tid 1]
[New pid 4010029 tid 2]
[New pid 4010029 tid 3]
[New pid 4010029 tid 4]

warning: the debug information found in "C:/QNX700//target/qnx7/x86/lib/libc.so.4.sym" does not match "C:/QNX700//target
/qnx7/x86/lib/libc.so.4" (CRC mismatch).

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xb0373873 in memset () from C:/QNX700//target/qnx7/x86/lib/libc.so.4
[Current thread is 3 (pid 4010029 tid 3)]
(gdb) where
#0  0xb0373873 in memset () from C:/QNX700//target/qnx7/x86/lib/libc.so.4
#1  0x08136536 in WebSocketConnection::receiveData...
View Full Message
Re: QNX 7 Memory Model / Compiler Question  
Forgot to show how I'm allocating the memory in case that matters / has changed via gcc

mInputPacket = new char [MAX_FRAME_SIZE];

Tim
Re: QNX 7 Memory Model / Compiler Question  
>>>I'm trying to find a way to confirm that everything is properly running in 32 bit mode (O/S, compiler, linker, 
libraries

To verify a binary architecture (ON HOST) use objdump.  For example,

>ntox86_64-objdump -x C:\qnx700\target\qnx7\x86_64\liblibpci.so | more

libpci.so:     file format elf64-x86-64
libpci.so
architecture: i386:x86-64, flags 0x00000150:
HAS_SYMS, DYNAMIC, D_PAGED


On target, you can use ldd

# ldd /bin/sh
/bin/sh:
        libc.so.4 => /usr/lib/ldqnx-64.so.2 (0x0)

   vs ldqnx.so.2


This should guarantee the image is 32-bit (as you showed).
[virtual=x86,bios +compress] boot = {
	startup-x86 -v

...vs [virtual=x86_64,



>>>I note in another post below mine someone having trouble allocating large buffers (2+ megs). 
I don't know if this is an issue, but you can verify in a much simpler program containing only the allocation and 
memset().

Dennis

 
Re: QNX 7 Memory Model / Compiler Question  
Dennis,

Thanks that helped and I was able to solve my problem.

Tim