编译 linux 内核 2.4.0 时发生内联汇编错误
inline assembly error while compiling linux kernel 2.4.0
我正在尝试在 Ubuntu 15.10 32 位上编译 linux 内核 2.4.0。我在构建时收到此错误:
linux/include/asm/checksum.h:161:2: 错误:缺少终止 " 字符
linux/include/asm/checksum.h:173:3: 错误:缺少终止 " 字符
...
gcc 抱怨的是内联汇编中的引号:
static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
struct in6_addr *daddr,
__u32 len,
unsigned short proto,
unsigned int sum)
{
__asm__("
addl 0(%1), %0 //line 162
adcl 4(%1), %0
adcl 8(%1), %0
adcl 12(%1), %0
adcl 0(%2), %0
adcl 4(%2), %0
adcl 8(%2), %0
adcl 12(%2), %0
adcl %3, %0
adcl %4, %0
adcl [=11=], %0
" // line 173
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
"r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
return csum_fold(sum);
}
我不确定为什么会这样。是不是因为gcc版本不兼容?我当前的 gcc 版本是
gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010.
Multi-line 最近的 gcc 不支持字符串文字。较新的(2.4.0 是古老的!)内核版本有:
asm("addl 0(%1), %0 ;\n"
"adcl 4(%1), %0 ;\n"
等它曾经被支持,例如 version 3.2, but the support was removed in 3.3:
The preprocessor no longer accepts multi-line string literals. They were deprecated in 3.0, 3.1, and 3.2.
我正在尝试在 Ubuntu 15.10 32 位上编译 linux 内核 2.4.0。我在构建时收到此错误:
linux/include/asm/checksum.h:161:2: 错误:缺少终止 " 字符 linux/include/asm/checksum.h:173:3: 错误:缺少终止 " 字符 ...
gcc 抱怨的是内联汇编中的引号:
static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
struct in6_addr *daddr,
__u32 len,
unsigned short proto,
unsigned int sum)
{
__asm__("
addl 0(%1), %0 //line 162
adcl 4(%1), %0
adcl 8(%1), %0
adcl 12(%1), %0
adcl 0(%2), %0
adcl 4(%2), %0
adcl 8(%2), %0
adcl 12(%2), %0
adcl %3, %0
adcl %4, %0
adcl [=11=], %0
" // line 173
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
"r"(htonl(len)), "r"(htonl(proto)), "0"(sum));
return csum_fold(sum);
}
我不确定为什么会这样。是不是因为gcc版本不兼容?我当前的 gcc 版本是 gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010.
Multi-line 最近的 gcc 不支持字符串文字。较新的(2.4.0 是古老的!)内核版本有:
asm("addl 0(%1), %0 ;\n"
"adcl 4(%1), %0 ;\n"
等它曾经被支持,例如 version 3.2, but the support was removed in 3.3:
The preprocessor no longer accepts multi-line string literals. They were deprecated in 3.0, 3.1, and 3.2.