Include binary file with GNU ld linker script

You could try using objcopy to convert it to a normal object you can link in, and then reference its symbols in the linker script like you would do to a normal object. From the objcopy manual page: -B bfdarch –binary-architecture=bfdarch Useful when transforming a raw binary input file into an object file. In this … Read more

Find nth SET bit in an int

Nowadays this is very easy with PDEP from the BMI2 instruction set. Here is a 64-bit version with some examples: #include <cassert> #include <cstdint> #include <x86intrin.h> inline uint64_t nthset(uint64_t x, unsigned n) { return _pdep_u64(1ULL << n, x); } int main() { assert(nthset(0b0000’1101’1000’0100’1100’1000’1010’0000, 0) == 0b0000’0000’0000’0000’0000’0000’0010’0000); assert(nthset(0b0000’1101’1000’0100’1100’1000’1010’0000, 1) == 0b0000’0000’0000’0000’0000’0000’1000’0000); assert(nthset(0b0000’1101’1000’0100’1100’1000’1010’0000, 3) == 0b0000’0000’0000’0000’0100’0000’0000’0000); assert(nthset(0b0000’1101’1000’0100’1100’1000’1010’0000, … Read more

Varbinary vs Blob in MySQL

VARBINARY is bound to 255 bytes on MySQL 5.0.2 and below, to 65kB on 5.0.3 and above. BLOB is bound to 65kB. Ultimately, VARBINARY is virtually the same as BLOB (from the perspective of what can be stored in it), unless you want to preserve compatibility with “old” versions of MySQL. The MySQL Documentation says: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)