You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "no1wudi (via GitHub)" <gi...@apache.org> on 2024/07/26 08:42:46 UTC
[PR] dlfcn: Add stub for dladdr [nuttx]
no1wudi opened a new pull request, #12777:
URL: https://github.com/apache/nuttx/pull/12777
## Summary
Implement a stub for dladdr() to avoid build errors with some applications that use dladdr().
The API definition is from:
1. https://man7.org/linux/man-pages/man3/dladdr.3.html
2. https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/dladdr.html
## Impact
New API
## Testing
Local machine
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#issuecomment-2252305678
> Please ignore the style issue since the definition is from POSIX.
@no1wudi let's add Dl_info to https://github.com/apache/nuttx/blob/master/tools/nxstyle.c#L187
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#discussion_r1692832046
##########
include/dlfcn.h:
##########
@@ -309,6 +321,26 @@ int dlclose(FAR void *handle);
FAR char *dlerror(void);
+/****************************************************************************
+ * Name: dladdr
+ *
+ * Description:
+ * dladdr() provides information about the address of a symbol in a
+ * dynamically loaded object.
+ *
+ * Input Parameters:
+ * addr - The address of the symbol for which information is desired.
+ * info - A pointer to a Dl_info structure that is filled in by dladdr().
+ *
+ * Returned Value:
+ * On success, these functions return a nonzero value.
+ *
+ * Reference: OpenGroup.org
+ *
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info);
Review Comment:
It's a little confuse the `Dl_info_t` is from POSIX, but `Dl_info` seems used more widely:
https://github.com/rust-lang/libc/blob/0e28c864c25d2e9b0ab082947445efccef213da4/src/unix/mod.rs#L1394
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#discussion_r1692832046
##########
include/dlfcn.h:
##########
@@ -309,6 +321,26 @@ int dlclose(FAR void *handle);
FAR char *dlerror(void);
+/****************************************************************************
+ * Name: dladdr
+ *
+ * Description:
+ * dladdr() provides information about the address of a symbol in a
+ * dynamically loaded object.
+ *
+ * Input Parameters:
+ * addr - The address of the symbol for which information is desired.
+ * info - A pointer to a Dl_info structure that is filled in by dladdr().
+ *
+ * Returned Value:
+ * On success, these functions return a nonzero value.
+ *
+ * Reference: OpenGroup.org
+ *
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info);
Review Comment:
It's a little confuse the `Dl_info_t` is from POSIX, but `Dl_info` (from Linux ?) seems used more widely:
https://github.com/rust-lang/libc/blob/0e28c864c25d2e9b0ab082947445efccef213da4/src/unix/mod.rs#L1394
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#discussion_r1692854343
##########
libs/libc/dlfcn/lib_dladdr.c:
##########
@@ -0,0 +1,42 @@
+/****************************************************************************
+ * libs/libc/dlfcn/lib_dladdr.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <dlfcn.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dladdr
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info)
+{
+ set_errno(ENOTSUP);
Review Comment:
If the specified address is not located within the address range occupied by an examined mapped object, or if an error occurs, zero shall be returned. More detailed diagnostic information shall be available through dlerror(), in current implementations, dlerror() return the errno (by strerror) directly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#discussion_r1692799151
##########
include/dlfcn.h:
##########
@@ -309,6 +321,26 @@ int dlclose(FAR void *handle);
FAR char *dlerror(void);
+/****************************************************************************
+ * Name: dladdr
+ *
+ * Description:
+ * dladdr() provides information about the address of a symbol in a
+ * dynamically loaded object.
+ *
+ * Input Parameters:
+ * addr - The address of the symbol for which information is desired.
+ * info - A pointer to a Dl_info structure that is filled in by dladdr().
+ *
+ * Returned Value:
+ * On success, these functions return a nonzero value.
+ *
+ * Reference: OpenGroup.org
+ *
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info);
Review Comment:
DL_info_t?
##########
libs/libc/dlfcn/lib_dladdr.c:
##########
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * libs/libc/dlfcn/lib_dladdr.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <dlfcn.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dladdr
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info)
+{
+ return -ENOTSUP;
Review Comment:
shouldn't it return 0?
##########
tools/nxstyle.c:
##########
@@ -184,6 +184,7 @@ static const struct file_section_s g_section_info[] =
static const char *g_white_prefix[] =
{
"ASCII_", /* Ref: include/nuttx/ascii.h */
+ "Dl_info", // Ref: include/dlfcn.h */
Review Comment:
broken comment
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "yamt (via GitHub)" <gi...@apache.org>.
yamt commented on code in PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#discussion_r1692838795
##########
libs/libc/dlfcn/lib_dladdr.c:
##########
@@ -0,0 +1,42 @@
+/****************************************************************************
+ * libs/libc/dlfcn/lib_dladdr.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <dlfcn.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: dladdr
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info)
+{
+ set_errno(ENOTSUP);
Review Comment:
is this supposed to use errno, not dlerror?
##########
include/dlfcn.h:
##########
@@ -309,6 +321,26 @@ int dlclose(FAR void *handle);
FAR char *dlerror(void);
+/****************************************************************************
+ * Name: dladdr
+ *
+ * Description:
+ * dladdr() provides information about the address of a symbol in a
+ * dynamically loaded object.
+ *
+ * Input Parameters:
+ * addr - The address of the symbol for which information is desired.
+ * info - A pointer to a Dl_info structure that is filled in by dladdr().
+ *
+ * Returned Value:
+ * On success, these functions return a nonzero value.
+ *
+ * Reference: OpenGroup.org
+ *
+ ****************************************************************************/
+
+int dladdr(const FAR void *addr, FAR Dl_info *info);
Review Comment:
then it's better to explain it in the above comment i guess.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on PR #12777:
URL: https://github.com/apache/nuttx/pull/12777#issuecomment-2252270137
Please ignore the style issue that the definition is from POSIX.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] dlfcn: Add stub for dladdr [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #12777:
URL: https://github.com/apache/nuttx/pull/12777
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org