小编Rus*_*hPL的帖子

分析ELF部分和符号大小的工具

我需要一种方法来分析我的GCC编译器的ARM输出文件.我正在编制裸机,我非常关心尺寸.我可以使用arm-none-eabi-objdump交叉编译器提供但是如果存在用于此任务的工具,则解析输出不是我想要做的事情.你知道这样的工具存在吗?我的搜索没有结果.

还有一件事,我自己的代码中的每个函数都在它自己的部分.

c parsing gcc cross-compiling objdump

26
推荐指数
2
解决办法
3万
查看次数

ASTC软件纹理压缩/解压缩算法

今天OpenGL 4.3和OpenGL ES 3.0规范已经推出,对于纹理压缩,他们将使用新开发的ASTC纹理压缩算法.如果算法中存在任何纯软件实现(最好用C/C++),我感兴趣.有一些代码片段在这里,但他们只覆盖在核心算法中使用的随机哈希,整篇文章没有披露.我将我的一个项目基于Squish项目(软件中的DXT1),并且对它将从ASTC中受益多少感兴趣.如果您有任何资源,请提前感谢.

c opengl algorithm graphics

6
推荐指数
1
解决办法
1779
查看次数

PEG.js输入结束的麻烦

我正在尝试为PEG.js写一个简单的语法来匹配这样的东西:

some text;
arbitrary other text that can also have µnicode; different expression;
let's escape the \; semicolon, and \not recognized escapes are not a problem;
possibly last expression not ending with semicolon
Run Code Online (Sandbox Code Playgroud)

所以基本上这些是用分号分隔的一些文本.我的简化语法看起来像这样:

start
= flow:Flow

Flow
= instructions:Instruction*

Instruction
= Empty / Text

TextCharacter
= "\\;" /
.

Text
= text:TextCharacter+ ';' {return text.join('')}

Empty
= Semicolon

Semicolon "semicolon"
= ';'
Run Code Online (Sandbox Code Playgroud)

问题是,如果我在输入中放入除分号以外的任何内容,我会得到:

SyntaxError: Expected ";", "\\;" or any character but end of input found.
Run Code Online (Sandbox Code Playgroud)

怎么解决这个?我已经读过PEG.js无法匹配输入结束.

javascript parsing peg pegjs

5
推荐指数
1
解决办法
2566
查看次数

LTO 模式下 ARM 的 GCC 8 正在删除中断处理程序和弱函数 - 如何防止它?

我的目标设备是基于 EFM32 Cortex-M3 的设备。我的工具链是官方的 ARM GNU 工具链 gcc-arm-none-eabi-8-2018-q4-major。

在没有 LTO 的情况下一切正常,但为了使 LTO 工作,我必须用-fno-lto. 我想摆脱这种解决方法。

问题是,每个中断处理程序都从最终的二进制文件中删除。(我正在检查arm-none-eabi-nm --print-size --size-sort --radix=d -C -n file.out)这会导致二进制崩溃。

在谷歌搜索类似问题后进行更深入的挖掘:

来自startup_efm32gg.c定义默认中断处理程序的示例代码如下:

void DMA_IRQHandler(void) __attribute__ ((weak, alias("Default_Handler")));
/* many other interrupts */
void Default_Handler(void) { while (1); }
Run Code Online (Sandbox Code Playgroud)

常规中断处理程序定义也会发生同样的问题(例如,没有别名且不弱)

这可能是相关的,但似乎弱符号在 LTO 模式下也以同样的方式运行不正常。

提前感谢您的任何想法!

编辑:有关完整解决方案,请参阅我对标记答案的回复!

c gcc arm lto

5
推荐指数
1
解决办法
1306
查看次数

C++ 11编译时间格式字符串文字构造,用于调用printf

我想做的是创建:

template<Args... args)>
int println(Args...) {
  // implementation which calls:
  // printf("<string literal format string at compile time>", args...);
  // additional perk would be compile time type checking
  // I expect to provide a format string for each type by some template
  // specialization.
}
Run Code Online (Sandbox Code Playgroud)

我一直在用编译时字符串文字分析两个有趣的工作:

基本上我或多或少能够静态地推断格式所需的字符串文字的长度,但仅仅是编译器拒绝将我的工作视为constexpr.另一个大问题是,当使用上述链接中的constexpr字符串时,编译器永远无法推断出结果字符串的大小.

我越努力实现这一点,我的无知就越多,超过了我的热情.我将不胜感激任何解决部分或全部问题的技巧和/或代码示例.

注意:我不是在寻找有关使用不同形式的日志记录的建议,例如通过cout.

注意2:不应该使用任何std :: string,因为它们是运行时

注3:通常所有类型安全的printfs都使用不同的方法,我很熟悉这可以通过多次调用轻松完成printf.我想一次性完成.我也知道缓冲区可以逐步构建,但这个问题是关于构造格式字符串.:)

更新:基本上代码的哪个部分需要实现

constexpr const char* formatString = build_compile_time_format_string(args...);
// build_compile_time_format_string(3, "hi", -3.4)
//     should evaluate to "%d %s %f"
//          or to …
Run Code Online (Sandbox Code Playgroud)

c++ templates metaprogramming c++11

4
推荐指数
1
解决办法
3113
查看次数

当身体有最小高度100%时身体的子元素不占用100%空间

以下代码正常工作

<!DOCTYPE html>
<html>
<head>
<title>Working</title>
<style type="text/css">
html {
  height: 100%;
}
body {
  height: 100%; /* !!!!! difference in here */
}
div#main {
  min-height: 100%;
  background-color: red;
}
</style>
</head>
<body>
    <div id="main"></div>
</body>
Run Code Online (Sandbox Code Playgroud)

而使用min-height代替heightfor body 的代码会阻止#main占用空间

<!DOCTYPE html>
<html>
<head>
<title>Not working</title>
<style type="text/css">
html {
  height: 100%;
}
body {
  min-height: 100%; /* !!!!! difference in here */
}
div#main {
  min-height: 100%;
  background-color: red;
}
</style>
</head>
<body> …
Run Code Online (Sandbox Code Playgroud)

html css

3
推荐指数
1
解决办法
1417
查看次数