gcc functions with constructor attribute are not being linked
I have a bunch of static libraries and they are interdependent. I faced problems while linking those libraries for my target because of dependencies. As a workaround I created one single archive file...
View Articlethere's a problem when I build my own crosstool with crosstool-4.3
When compiling cross-compiler tool crosstool-0.43 (for arm9) on the CentOS 7.5 64-bit system, I encountered the following error:cc -c -o flat_bl.o...
View ArticleGCC Loop Increment Optimization -O2 and above
I've been doing some research involving optimization and loop unrolling and I've been looking at the generated assembly code for different optimization levels. I've come across a weird optimization...
View ArticleHow is this gcc-generated strlen() mips loop not off-by-one?
Here is the source code for a very basic strlen() implementation.#include <stddef.h> #include <stdint.h> extern uintptr_t lx_syscall3(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t nr);...
View ArticleHow to run Newlib applications using QEMU?
I wrote an application that uses several trigonometric functions (sin, tan, cos, ...). My objective is to study the different implementations of these functions in the GNU C library, MUSL, and...
View ArticleHow to print result of a compile-time calculation in C++?
I've wrote several constexpr functions and use them in static_asserts to control some resource limits. But I'd like to not only enforce compile-time predicate but also to see the actual values...
View ArticleC++ bug when using range-based for loop and vector of pointers [duplicate]
This question already has an answer here:What is the correct way of using C++11's range-based for? 4 answersWhile messing around with vectors of pointers, I stumbled upon this weird...
View Articleuint32_t * uint32_t = uint64_t vector multiplication with gcc
I'm trying to multiply vectors of uint32_t producing the full 64bit result in an uint64_t vector in gcc. The result I expect is for gcc to emit a single VPMULUDQ instruction. But what gcc outputs as...
View ArticleC++ compile time result differs from run time result. Bug or valid behavior...
This question already has an answer here:Is floating point math broken? 31 answersI am doing a x86 cross compile using gcc 8.3.0 with -ffast-math enabled of the following code: #include <cmath>...
View ArticleLocation of scanf function family in VC runtime 2017 to be used in MinGW 7
I am using:VS 2017MinGW with GCC/G++ 7.4.0.Basically what is happening goes as follows:An executable is built using VS 2017An .so is built with GCCThe .so is loaded by the executable created in step...
View ArticleC array declaration with inline assembly
I recently came upon this snippet: extern const uint8_t server_root_cert_pem_start[] asm("_binary_server_root_cert_pem_start"); // ^^^^^^^^^^^^^ what's going on here? in the esp-idf examples(line 74)....
View ArticleCannot link any C program with gcc on Mac Mojave
I've just updated to OSX 10.14.6 (Mojave) and now, after upgrading Xcode and migrating MacPorts, even the simplest C program will not link with any gcc version. For example, linking the programint...
View ArticleHP-UX cc uses a default setting to allow null dereferences, is that possible...
From the HPUX cc, c89 - C compiler man page: -z Do not bind anything to address zero. This option allows runtime detection of null pointers. See the note on pointers below. -Z Allow dereferencing of...
View ArticleHow to bruteforce the stack canary
gcc implemented a stack protector, to protect programs for buffer overflows. I want to know, if its possible (and if it is how) to exploit this and run a buffer overflow. I created a simple python...
View ArticleMultiple inconsistent behavior of signed bit-fields
I have come across a strange behavior on signed bit-fields:#include <stdio.h> struct S { long long a31 : 31; long long a32 : 32; long long a33 : 33; long long : 0; unsigned long long b31 : 31;...
View ArticleWhy does MSVC (Visual C++) need separate dllimport and dllexport attributes...
I know why and when __declspec(dllimport) and __declspec(dllexport) are used in Visual C++.I know the GCC alternative to both __declspec(dllimport) and __declspec(dllexport) is...
View Articlegcc 6.3 --> Fatal Python error: Py_Initialize: Unable to get the locale...
I am trying to install a Python package and I get this error in CentOS7:Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings'Complete log...
View ArticleGCC: --whole-archive recipe for static linking to pthread stopped working in...
Static linking against pthread is a difficult topic on Linux. It used to work to wrap -lpthread as -Wl,--whole-archive -lpthread -Wl,--no-whole-archive (the details can be found in this answer).The...
View ArticleCan g++ 5.4 link the library that is compiled by g++ 4.8?
I compile a c++ program by g++5.4, which links a library compiled by g++4.8. I have set -D_GLIBCXX_USE_CXX11_ABI=0 and the program compiled successfully. However i got Segmentation fault when running...
View ArticleSegmentation Fault when editing code of executable file
Working on a Cyber Security Project: When editing the code of a .exe file in c, it's possible to edit the code of a different exe file but not the exe file itself. It results in a segmentation fault....
View Article