在solaris 64位函数指针的问题 [英] Solaris 64 bit function pointer problem

查看:212
本文介绍了在solaris 64位函数指针的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境: 操作系统:Sun Solaris上10 处理器:AMD 64位

Environment: OS: Sun Solaris 10 Processor: AMD 64 bit

我有它使用的net-snmp库的应用程序。该应用程序是便携式(code级),以不同的操作系统和处理器。在NET-SNMP,你可以注册一个日志回调(函数指针),它被调用时,事情将被记录。

I have an application which uses net-snmp library. The application is portable (code level) to various OS and processor. In net-snmp, you can register a logging callback (a function pointer) which gets called when something is to be logged.

现在的问题是,当我运行该应用程序,它赛格故障时的net-snmp尝试拨打我已经注册了回调函数。这被注册的回调地址0xffe30b90但NET-SNMP试图调用为0xffffffff ffe30b90。

The problem is that when I run the application, it seg faults when net-snmp tries to call the callback function I have registered. The callback address that gets registered is 0xffe30b90 but net-snmp tries to call 0xffffffff ffe30b90.

在调查,我写在同一个应用程序的另一个功能,并将其注册。该函数被调用正确的,但它的地址显示为0x52e060(无领导FF)。

While investigating, I wrote another function in the same application and registered it. That function gets called properly but it's address shows as 0x52e060 (no leading ff).

我无法找出这里的问题是。这似乎是一些相关的字节对齐或某些指针溢出的问题。

I am not able to figure out what the problem here is. It seems to be something related to byte alignment or some pointer overflow problem.

任何指针作进一步调查将AP preciated。谢谢你,

Any pointers for further investigation will be appreciated. Thanks,

-Farooque

-Farooque

推荐答案

听起来像是某个地址被通过为有符号32位int,它获取转换回64位时,符号扩展,增加额外的0xFFFF的...位。确保你的code不认为 INT 是相同的大小为指针的任何地方,因为64位Solaris ABI使用LP64约定,在那里 INT 是32位,而和指针是64位的。

Sounds like somewhere the address is being passed through as a signed 32-bit int, which gets sign-extended when converting back to 64-bit, adding the extra 0xFFFF... bits. Make sure your code doesn't assume that int is the same size as a pointer anywhere, since the Solaris 64-bit ABI uses the "LP64" conventions, where int is 32-bits, while long and pointers are 64-bit.

这篇关于在solaris 64位函数指针的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆