Compiling Splat! on Ubuntu 8.10 x86_64
SPLAT! is an RF Signal Propagation, Loss, And Terrain analysis tool for the spectrum between 20 MHz and 20 GHz.
Unfortunately, compiling this out of the box threw a number of compiler errors. Here’s what I found & how I fixed it.

Target system:
-
Ubuntu 8.10 x86_64 (64 bit)
Supporting libraries installed for this program:
-
libbz2-dev
-
libzzip-dev
-
llib1g-dev
splat.cpp
Problem:
Compiler complains of a potential buffer overrun
Details:
Offending lines are here:
line 1663 strncat(path_plus_name,sdf_file,255);
line 1896 strncat(path_plus_name,sdf_file,255);
The offending variables are declared here:
line 1612 char path_plus_name[255]
line 1842 char path_plus_name[255]
Solution:
Double the path_plus_name char size to 512 bytes
Explanation:
On lines 1663 and 1896 strncat creates a potential buffer overrun condition by concatenating sdf_file[255] with path_plus_name[255]. There is some earlier logic that ensures this won’t happen, but the compiler throws a fit regardless. This is corrected by doubling the path_plus_name size to 512 byte.
Line 1612 modified char path_plus_name[512]
Line 1852 modified char path_plus_name[512]
Background:
char * strncat ( char * destination, char * source, size_t num );
Appends the first num characters of source to destination, plus a terminating null-character. If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.
destination
Pointer to the destination array, which should contain a C string, and be large enough to contain the concatenated resulting string, including the additional null-character.
source
C string to be appended.
num
Maximum number of characters to be appended.
Build Error Messages:
Compiling SPLAT!…
In function ‘char* strncat(char*, const char*, size_t)’,
inlined from ‘int LoadSDF_SDF(char*)’ at splat.cpp:1663:
/usr/include/bits/string3.h:153: warning: call to char* __builtin___strncat_chk(char*, const char*, long unsigned int, long unsigned int) might overflow destination buffer
In function ‘char* strncat(char*, const char*, size_t)’,
inlined from ‘int LoadSDF_BZ(char*)’ at splat.cpp:1896:
/usr/include/bits/string3.h:153: warning: call to char* __builtin___strncat_chk(char*, const char*, long unsigned int, long unsigned int) might overflow destination buffer
Done!
Compiling SPLAT! HD…
In function ‘char* strncat(char*, const char*, size_t)’,
inlined from ‘int LoadSDF_SDF(char*)’ at splat.cpp:1663:
/usr/include/bits/string3.h:153: warning: call to char* __builtin___strncat_chk(char*, const char*, long unsigned int, long unsigned int) might overflow destination buffer
In function ‘char* strncat(char*, const char*, size_t)’,
inlined from ‘int LoadSDF_BZ(char*)’ at splat.cpp:1896:
/usr/include/bits/string3.h:153: warning: call to char* __builtin___strncat_chk(char*, const char*, long unsigned int, long unsigned int) might overflow destination buffer
Compiling srtm2sdf…
In function ‘strncat’,
inlined from ‘LoadSDF_SDF’ at srtm2sdf.c:264:
/usr/include/bits/string3.h:153: warning: call to __builtin___strncat_chk might overflow destination buffer
In function ‘strncat’,
inlined from ‘LoadSDF_BZ’ at srtm2sdf.c:371:
/usr/include/bits/string3.h:153: warning: call to __builtin___strncat_chk might overflow destination buffer
splat.cpp
Problem:
Building with parameter (8) 8 x 8 Degrees ——— 3330 Megabytes minimum”
sets the following in hd-parms.h
#define MAXPAGES 64
and causes compiler link errors:
collect2: ld returned 1 exit status
Explanation:
For some reason the branches are too large for the opcode field. (Don’t know enough about the GCC compiler at this time to explain in more detail.)
Solution:
Use a smaller build parameter. (6) worked for me.
Output of the faultly build:
Compiling SPLAT! HD… /tmp/cc0XOrhm.o: In function `LoadDBMColors(site)’:
splat.cpp:(.text+0x2cc): relocation truncated to fit: R_X86_64_PC32 against symbol `region’ defined in .bss section in /tmp/cc0XOrhm.o
splat.cpp:(.text+0x2d6): relocation truncated to fit: R_X86_64_PC32 against symbol `region’ defined in .bss section in /tmp/cc0XOrhm.o
splat.cpp:(.text+0x2ff): relocation truncated to fit: R_X86_64_PC32 against symbol `region’ defined in .bss section in /tmp/cc0XOrhm.o
…
splat.cpp:(.text+0×343): relocation truncated to fit: R_X86_64_PC32 against symbol `region’ defined in .bss section in /tmp/cc0XOrhm.o
splat.cpp:(.text+0x34a): additional relocation overflows omitted from the output
collect2: ld returned 1 exit status
srtm2sdf.c
Problem:
Same buffer overrun complaint as splat.cpp
Solution:
Same solution: double the size of path_plus_name[255] to [512] in two places:
Line 264 modified char path_plus_name[512]
Line 371 modified char path_plus_name[512]
Build Error messages:
Compiling srtm2sdf… In function ‘strncat’,
inlined from ‘LoadSDF_SDF’ at srtm2sdf.c:264:
/usr/include/bits/string3.h:153: warning: call to __builtin___strncat_chk might overflow destination buffer
In function ‘strncat’,
inlined from ‘LoadSDF_BZ’ at srtm2sdf.c:371:
/usr/include/bits/string3.h:153: warning: call to __builtin___strncat_chk might overflow destination buffer
Links >
