如何使用GCC生成IP相对寻址指令(How to generate IP relative addressing instructions with GCC)
我写了一个小程序来测试GCC的选项。
int main() { int a=0; __asm__("movl %0,%%ecx\n" "jmp jmpsection\n" "inc %%ecx\n" "jmpsection: movl $1,%%eax\n" "movl $0,%%ebx\n" "int $0x80\n"::"a"(a):"ecx","ebx"); }
为了使var等于1,跳过inc指令。 我想强制GCC使用IP相对寻址方法生成jmp指令。 我已经搜索了GCC手册以找到解决方案,但我很害怕。 谢谢你重播。
I wrote a small program to test GCC's options.
int main() { int a=0; __asm__("movl %0,%%ecx\n" "jmp jmpsection\n" "inc %%ecx\n" "jmpsection: movl $1,%%eax\n" "movl $0,%%ebx\n" "int $0x80\n"::"a"(a):"ecx","ebx"); }
In order to keep var a equal to 1, skip the inc instruction. I want to force GCC to generate the jmp instruction using IP relative addressing method. I have searched the GCC manual to find a solution, but I feiled. Thanks for replay.
原文:https://stackoverflow.com/questions/10246974
最满意答案
通过检查,您的makefile应如下所示:
main: main.o ChiSquared.o StatTests.o ChiSquaredTest.o KS.o ChiSquared.o $(CXX) $(CXXFLAGS) -o main $^ ChiSquared.o: ChiSquared.cpp ChiSquared.h GaussQuad.h ChiSquaredTest.o: ChiSquaredTest.cpp ChiSquaredTest.h ChiSquared.h GaussQuad.h KS.o: KS.cpp KS.h ChiSquared.h GaussQuad.h StatTests.o: StatTests.cpp StatTests.h ChiSquaredTest.h KS.h ChiSquared.h GaussQuad.h Main.o: Main.cpp StatTests.h ChiSquaredTest.h KS.h ChiSquared.h GaussQuad.h
(注意使用自动变量
$^
而不是显式的目标文件列表。)要注意两件事:
1)我敢打赌你实际上并不需要
#include
彼此的所有头文件; 在高级别过多使用#include
会导致不必要的依赖,从而导致不必要的重建。2)无需手动在makefile中维护这些先决条件列表; Make可以为你做。 但这是一种先进的技术,所以让我们先让你的简单makefile工作。
By inspection, your makefile should look something like this:
main: main.o ChiSquared.o StatTests.o ChiSquaredTest.o KS.o ChiSquared.o $(CXX) $(CXXFLAGS) -o main $^ ChiSquared.o: ChiSquared.cpp ChiSquared.h GaussQuad.h ChiSquaredTest.o: ChiSquaredTest.cpp ChiSquaredTest.h ChiSquared.h GaussQuad.h KS.o: KS.cpp KS.h ChiSquared.h GaussQuad.h StatTests.o: StatTests.cpp StatTests.h ChiSquaredTest.h KS.h ChiSquared.h GaussQuad.h Main.o: Main.cpp StatTests.h ChiSquaredTest.h KS.h ChiSquared.h GaussQuad.h
(Note the use of the automatic variable
$^
instead of an explicit list of the object files.)Be aware of two things:
1) I'll bet you don't actually need to
#include
all those header files in each other; too much use of#include
at high levels causes unnecessary dependency, which leads to unnecessary rebuilding.2) There's no need to maintain these prerequisite lists in the makefile by hand; Make can do it for you. But that's an advanced technique, so let's get your simple makefile working first.
相关问答
更多-
您可以通过运行bower update更新所有。 在任何命令上使用-h标志来查看如何使用它。 比如bower update -h 。 You can update all by running bower update. Use the -h flag on any command to see how you can use it. Eg bower update -h.
-
War文件的Maven依赖关系排除,但包含测试(Maven dependency exclusion for War file, but inclusion for tests)[2023-11-10]
在你的依赖中使用“范围”标签。test http://maven.apache.org/pom.html#Dependencies 编辑:如果我正确理解您的配置,那么您需要添加的scope = test应添加到mygroup.myartifact POM中。 通过这种方式,您可以使用包含jdbc jar的工具来测试工件,但是当其他POMS需要包含mygroup.myartifact时,它们不会将jdbc作为传递依赖包含在内。 第二个编辑:好的,如果你不控制你想包含的POM ... -
我会尝试在记事本或Notepad ++等测试编辑器中打开csproj文件,并确定引用是否指向正确的dll(s)。 另外要注意,因为某些引用可能包含签名,也可能不是正确的签名。 IDE上显示的内容可能与csproj文件中的内容完全不同。 您需要从VS卸载项目才能在文本编辑器中编辑它。 此外,还为解决方案上的所有项目执行此操作。 I would try opening the csproj file in a test editor like Notepad or Notepad++ and figure ou ...
-
TeamCity的NuGet包包含版本号字段。 如果你使用AssemblyInfoPatcher,我们可以使用我们在那里指定的数字。 对于使用文件内容替换器的更复杂方法,从编译后的dll读取版本号的小型PowerShell脚本可以帮助并将其存储在teamcity配置参数%ActualVersion%中 $DllFileName = "MyDll.dll" $PathPrefix = "bin/Release/" $Version = [System.Diagnostics.FileVersionInfo]: ...
-
感谢CrazyCoder,我导出了Module A所有依赖关系 对于同一个.jar的多个依赖关系。 我只是将android-support-v4.jar设置为Project Library 。 阅读Intellij之后:android-support-v4.jar包含在actionBarSherlock和Project => IllegalArgumentException中 。 我在所有引用它的模块中将范围从Compile更改为android-support-v4的Provided 。 Thanks to ...
-
通过检查,您的makefile应如下所示: main: main.o ChiSquared.o StatTests.o ChiSquaredTest.o KS.o ChiSquared.o $(CXX) $(CXXFLAGS) -o main $^ ChiSquared.o: ChiSquared.cpp ChiSquared.h GaussQuad.h ChiSquaredTest.o: ChiSquaredTest.cpp ChiSquaredTest.h ChiSquared.h Gaus ...
-
你应该通过: InputStream is = this.getClass().getResourcesAsStream("/myfile.properties"); You should go via: InputStream is = this.getClass().getResourcesAsStream("/myfile.properties");
-
带有依赖项的nuspec文件(nuspec file with dependencies)[2021-07-22]
Dependencies部分是您可以指定要定位的其他nuget包(正如您所做)。 查看第一个链接中的“依赖关系组”部分。 您可能为依赖项指定了错误的组类型。 以下是目标框架的列表 。 我怀疑你可以删除组标记并保留标记。 以下是依赖项的示例(来自您提供的列表): 您可以在compileOnly配置中声明依赖项,以便它们不会在war中包装。 dependencies { compileOnly 'a:a:1.0' compileOnly 'b:b:2.0' } 然后你可以从compileOnly配置创建一个超级jar task uberJar(type: Jar) { configurations.compileOnly.files.each { File jar -> from zipTree(jar) } ...IMO它取决于您的确切用例。 选项1当然是一个很好的方法,但是如果你已经拥有一个父项目,那么管理会变得更加困难/复杂,特别是如果你有多个共享依赖集(你可能会发现自己迷失在多个父项的复杂层次结构中) )。 选项1的另一个缺点是(AFAIK)不可能排除继承的依赖项,所以如果你的项目扩展了父pom,你别无选择,只能继承所有的依赖项。 在这种情况下,选项2更易于管理,更清晰,更灵活。 创建一个POM类型的maven项目,并在需要时添加一个依赖项。 使用此解决方案,可以从POM项目中排除某些依赖项,这再次使此解决方案 ...相关文章
更多- TCP/IP 是如何寻址
- Multicast over TCP/IP HOWTO
- RFC2848--The PINT Service Protocol: Extensions to SIP and SDP for IP Access to Telephone Call Services
- ios获取ip地址
- LVS集群:IP负载均衡
- linux下可以限制IP地址对FTP功能的访问吗?
- JavaMail如何获取邮件发送者的IP?
- TCP/IP 相关协议解释
- TCP/IP 发送邮件原理
- Hadoop集群搭建(IP设置和JDK安装)
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)