Das klingt plausibel und kann ich nachvollziehen.
Ein Adress-struct für ein Unix-Socket sieht so aus:
struct sockaddr_un {
sa_family_t sun_family;
char sun_path[108];
};
sa_family_t ist ein 16-Bit-Integer, also kommt das struct normalerweise bei 2+108=110 Byte heraus. Wenn man aber die von dir angegebene Option -mstructure-size-boundary=32 nutzt, bläst der Compiler das struct auf das nächste Vielfache von 32 Bit, also 112 Byte auf, und wenn man im bind-Systemaufruf dann wahrheitsgemäß 112 Byte als Größe der Adresse für ein Unix-Socket übergibt, verweigert der Kernel das mit EINVAL.
Zitat
EINVAL addrlen is wrong, or addr is not a valid address for this socket's domain.
Dieses minimale C-Programm wirft einen Fehler auf Linux/arm, wenn es mit -mstructure-size-boundary=32 kompiliert wird, aber ohne (bzw. wenn man statt sizeof(testaddr) den Wert 110 hartkodiert) funktioniert es.
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#define SOCKET_PATH "/tmp/test.sock"
int main() {
struct sockaddr_un testaddr;
testaddr.sun_family = AF_UNIX;
strcpy(testaddr.sun_path, SOCKET_PATH);
int s = socket(AF_UNIX, SOCK_STREAM, 0);
int bind_res = bind(s, (struct sockaddr *) &testaddr, sizeof(testaddr));
if (bind_res) {
perror("bind");
return 1;
}
close(s);
unlink(SOCKET_PATH);
return 0;
}
Alles anzeigen
Das scheint im Übrigen ein bekanntes Problem mit Netzwerk-Stacks auf ARM zu sein.
gcc auf x86 kennt -mstructure-size-boundary schon gar nicht erst.