[{"id":3619,"web_url":"https://patchwork.libcamera.org/comment/3619/","msgid":"<20200206180738.GA7611@pendragon.ideasonboard.com>","date":"2020-02-06T18:07:38","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Wed, Feb 05, 2020 at 01:04:16PM +0000, Kieran Bingham wrote:\n> Provide a helper that will identify the DT_RUNPATH string from the\n> ELF dynamic library string table entries.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/libcamera/include/utils.h |  1 +\n>  src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n>  2 files changed, 27 insertions(+)\n> \n> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> index e467eb21c518..069b327bb436 100644\n> --- a/src/libcamera/include/utils.h\n> +++ b/src/libcamera/include/utils.h\n> @@ -33,6 +33,7 @@ namespace utils {\n>  const char *basename(const char *path);\n>  \n>  char *secure_getenv(const char *name);\n> +const char *get_runpath();\n>  \n>  template<class InputIt1, class InputIt2>\n>  unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> index 4beffdab5eb6..e48cf2b6a48e 100644\n> --- a/src/libcamera/utils.cpp\n> +++ b/src/libcamera/utils.cpp\n> @@ -7,7 +7,9 @@\n>  \n>  #include \"utils.h\"\n>  \n> +#include <elf.h>\n>  #include <iomanip>\n> +#include <link.h>\n>  #include <sstream>\n>  #include <stdlib.h>\n>  #include <string.h>\n> @@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n>  #endif\n>  }\n>  \n> +/**\n> + * \\brief Obtain the runpath string from the dynamic symbol table\n\nIt's the \"dynamic tags\" (.dynamic), not \"dynamic symbol table\"\n(.dynsym).\n\n> + * \\returns a const char pointer to the runpath entry in the elf string table\n\ns/returns/return/\n\nActually after checking the doxygen documentation \\returns is an alias\nfor \\return. Still, I think we should standardize on \\return.\n\ns/a const/A const/\n\nMaybe s/elf/ELF/ ?\n\n> + * or NULL if it is not found.\n\ns/\\.$//\n\n> + */\n> +const char *get_runpath()\n\nWe only use this function in a single location, I'm tempted to move it\nto ipa_manager.cpp. If we want to create ELF-related helpers, then\nmoving this, along with the ELF code from ipa_module.cpp to an elf.cpp\nfile could be useful, but would be overkill for now.\n\nHow about calling it elf_get_runpath(), elf_runpath(), or elfRunPath() ?\nThe latter is more compliant with our coding style. The reason why most\nother functions in this file use snake case instead of camel case is\nbecause they mimic the glibc or libstdc++ APIs.\n\n> +{\n> +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n> +\tconst ElfW(Dyn) *runpath = NULL;\n\n%s/NULL/nullptr/\n\n> +\tconst char *strtab = NULL;\n> +\n> +\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n\nMaybe\n\n\tfor (const ELFW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n\n?\n\nDo I understand correctly that _DYNAMIC is the dynamic tags array for\nthe current ELF binary, and thus always corresponds to libcamera.so, not\nthe code calling get_runpath() ? That's what we need, but I think it\nshould be documented.\n\n> +\t\tif (dyn->d_tag == DT_STRTAB)\n> +\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n> +\t\telse if (dyn->d_tag == DT_RUNPATH)\n> +\t\t\trunpath = dyn;\n> +\t}\n> +\n> +\tif (strtab && runpath)\n> +\t\treturn strtab + runpath->d_un.d_val;\n> +\n> +\treturn NULL;\n\nnullptr here too.\n\n> +}\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\n>  /**\n>   * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n>   *\t\t\t\t     InputIt2 first2, InputIt2 last2)","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7903B60864\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 19:07:54 +0100 (CET)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DA3A39F0;\n\tThu,  6 Feb 2020 19:07:53 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581012474;\n\tbh=ko+9NRtLBkGbcGZgUveh/5mCFMxtWOELh5XGUKHMMSs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=lNYjfov9VNA3Kp1bgE/rCGcdSDm5RSRULMjBkpi3xqVw63ZFZsS8M+0/anLVyNn2N\n\tQBmDueztKGaOaEtWas9S10MV84bu7/ZOz3L+tn5ExDFsU7w1r9UH9hzImfBvJRDYB0\n\tZw/KTrY1A/xSySTFfkPuLhHVXI9GFTy9FkIsnTcg=","Date":"Thu, 6 Feb 2020 20:07:38 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200206180738.GA7611@pendragon.ideasonboard.com>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200205130420.8736-2-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 06 Feb 2020 18:07:54 -0000"}},{"id":3625,"web_url":"https://patchwork.libcamera.org/comment/3625/","msgid":"<20200206210348.GA21834@pendragon.ideasonboard.com>","date":"2020-02-06T21:03:48","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nAnother comment.\n\nOn Thu, Feb 06, 2020 at 08:07:38PM +0200, Laurent Pinchart wrote:\n> On Wed, Feb 05, 2020 at 01:04:16PM +0000, Kieran Bingham wrote:\n> > Provide a helper that will identify the DT_RUNPATH string from the\n> > ELF dynamic library string table entries.\n> > \n> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  src/libcamera/include/utils.h |  1 +\n> >  src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n> >  2 files changed, 27 insertions(+)\n> > \n> > diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> > index e467eb21c518..069b327bb436 100644\n> > --- a/src/libcamera/include/utils.h\n> > +++ b/src/libcamera/include/utils.h\n> > @@ -33,6 +33,7 @@ namespace utils {\n> >  const char *basename(const char *path);\n> >  \n> >  char *secure_getenv(const char *name);\n> > +const char *get_runpath();\n> >  \n> >  template<class InputIt1, class InputIt2>\n> >  unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n> > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> > index 4beffdab5eb6..e48cf2b6a48e 100644\n> > --- a/src/libcamera/utils.cpp\n> > +++ b/src/libcamera/utils.cpp\n> > @@ -7,7 +7,9 @@\n> >  \n> >  #include \"utils.h\"\n> >  \n> > +#include <elf.h>\n> >  #include <iomanip>\n> > +#include <link.h>\n> >  #include <sstream>\n> >  #include <stdlib.h>\n> >  #include <string.h>\n> > @@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n> >  #endif\n> >  }\n> >  \n> > +/**\n> > + * \\brief Obtain the runpath string from the dynamic symbol table\n> \n> It's the \"dynamic tags\" (.dynamic), not \"dynamic symbol table\"\n> (.dynsym).\n> \n> > + * \\returns a const char pointer to the runpath entry in the elf string table\n> \n> s/returns/return/\n> \n> Actually after checking the doxygen documentation \\returns is an alias\n> for \\return. Still, I think we should standardize on \\return.\n> \n> s/a const/A const/\n> \n> Maybe s/elf/ELF/ ?\n> \n> > + * or NULL if it is not found.\n> \n> s/\\.$//\n> \n> > + */\n> > +const char *get_runpath()\n> \n> We only use this function in a single location, I'm tempted to move it\n> to ipa_manager.cpp. If we want to create ELF-related helpers, then\n> moving this, along with the ELF code from ipa_module.cpp to an elf.cpp\n> file could be useful, but would be overkill for now.\n> \n> How about calling it elf_get_runpath(), elf_runpath(), or elfRunPath() ?\n> The latter is more compliant with our coding style. The reason why most\n> other functions in this file use snake case instead of camel case is\n> because they mimic the glibc or libstdc++ APIs.\n> \n> > +{\n> > +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n\nbionic and musl don't seem to provide _DYNAMIC :-S They both have elf.h\nand link.h, with a definition of the macros and structures used below,\nbut _DYNAMIC seems to be missing. I may be missing something, it should\nbe tested.\n\n> > +\tconst ElfW(Dyn) *runpath = NULL;\n> \n> %s/NULL/nullptr/\n> \n> > +\tconst char *strtab = NULL;\n> > +\n> > +\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n> \n> Maybe\n> \n> \tfor (const ELFW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n> \n> ?\n> \n> Do I understand correctly that _DYNAMIC is the dynamic tags array for\n> the current ELF binary, and thus always corresponds to libcamera.so, not\n> the code calling get_runpath() ? That's what we need, but I think it\n> should be documented.\n> \n> > +\t\tif (dyn->d_tag == DT_STRTAB)\n> > +\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n> > +\t\telse if (dyn->d_tag == DT_RUNPATH)\n> > +\t\t\trunpath = dyn;\n> > +\t}\n> > +\n> > +\tif (strtab && runpath)\n> > +\t\treturn strtab + runpath->d_un.d_val;\n> > +\n> > +\treturn NULL;\n> \n> nullptr here too.\n> \n> > +}\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> > +\n> >  /**\n> >   * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n> >   *\t\t\t\t     InputIt2 first2, InputIt2 last2)","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A690960864\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 22:04:05 +0100 (CET)","from pendragon.ideasonboard.com\n\t(117.145-247-81.adsl-dyn.isp.belgacom.be [81.247.145.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 18C879F0;\n\tThu,  6 Feb 2020 22:04:04 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581023045;\n\tbh=glDocl2/JhN3WCNXh/Fxh2bV+oF0ChxstIUZEByr+Bs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=m2IXEp0K4Rzlo5ZTn8+6NOQ8xrxZ/plozLp44xHm9Mr+R4nejiXj5Nl9hI6E0Nvf5\n\tkdNfH/LuUdTdXZeocyWpQv8yvvHXOfvaWJMXp1ZzRZslS1vsUofrcLe1GPSA1PvQET\n\t28vg8cxczXGKVgw6/pMNKD4uzAr78+fVia6GRHzI=","Date":"Thu, 6 Feb 2020 23:03:48 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200206210348.GA21834@pendragon.ideasonboard.com>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>\n\t<20200206180738.GA7611@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200206180738.GA7611@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 06 Feb 2020 21:04:05 -0000"}},{"id":3653,"web_url":"https://patchwork.libcamera.org/comment/3653/","msgid":"<a66df126-6dca-601b-d163-372373ae7eb0@ideasonboard.com>","date":"2020-02-11T14:05:53","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/02/2020 18:07, Laurent Pinchart wrote:\n> Hi Kieran,\n> \n> Thank you for the patch.\n> \n> On Wed, Feb 05, 2020 at 01:04:16PM +0000, Kieran Bingham wrote:\n>> Provide a helper that will identify the DT_RUNPATH string from the\n>> ELF dynamic library string table entries.\n>>\n>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>> ---\n>>  src/libcamera/include/utils.h |  1 +\n>>  src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n>>  2 files changed, 27 insertions(+)\n>>\n>> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n>> index e467eb21c518..069b327bb436 100644\n>> --- a/src/libcamera/include/utils.h\n>> +++ b/src/libcamera/include/utils.h\n>> @@ -33,6 +33,7 @@ namespace utils {\n>>  const char *basename(const char *path);\n>>  \n>>  char *secure_getenv(const char *name);\n>> +const char *get_runpath();\n>>  \n>>  template<class InputIt1, class InputIt2>\n>>  unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n>> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n>> index 4beffdab5eb6..e48cf2b6a48e 100644\n>> --- a/src/libcamera/utils.cpp\n>> +++ b/src/libcamera/utils.cpp\n>> @@ -7,7 +7,9 @@\n>>  \n>>  #include \"utils.h\"\n>>  \n>> +#include <elf.h>\n>>  #include <iomanip>\n>> +#include <link.h>\n>>  #include <sstream>\n>>  #include <stdlib.h>\n>>  #include <string.h>\n>> @@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n>>  #endif\n>>  }\n>>  \n>> +/**\n>> + * \\brief Obtain the runpath string from the dynamic symbol table\n> \n> It's the \"dynamic tags\" (.dynamic), not \"dynamic symbol table\"\n> (.dynsym).\n> \n>> + * \\returns a const char pointer to the runpath entry in the elf string table\n> \n> s/returns/return/\n> \n> Actually after checking the doxygen documentation \\returns is an alias\n> for \\return. Still, I think we should standardize on \\return.\n\nLooks like I copied \\returns from the secure_getenv above.\n\nI'll send a patch to fix that, and the other one in the source code.\n\n <sent>\n\n> \n> s/a const/A const/\n> \n> Maybe s/elf/ELF/ ?\n> \n>> + * or NULL if it is not found.\n\ns/NULL/nullptr here of course too\n\nPerhaps NULL => nullptr should be in checkstyle.py.\n\n> \n> s/\\.$//\n> \n>> + */\n>> +const char *get_runpath()\n> \n> We only use this function in a single location, I'm tempted to move it\n> to ipa_manager.cpp. If we want to create ELF-related helpers, then\n\nIndeed, as it's only a single use and not expected to be used elsewhere\nit could be a local static.\n\nAt that point, the implementation can be squashed into the patch that\nneeds it too.\n\n\n> moving this, along with the ELF code from ipa_module.cpp to an elf.cpp\n> file could be useful, but would be overkill for now.\n\nIf we end up with any more ELF support, I'd like to see it all collected\ntogether indeed but for now it's fine.\n\n\n> How about calling it elf_get_runpath(), elf_runpath(), or elfRunPath() ?\n> The latter is more compliant with our coding style. The reason why most\n> other functions in this file use snake case instead of camel case is\n> because they mimic the glibc or libstdc++ APIs.\n\nI was mimicking the style of this file.\n\nI'll move to ipa_manager and use elfRunPath\n\n> \n>> +{\n>> +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n>> +\tconst ElfW(Dyn) *runpath = NULL;\n> \n> %s/NULL/nullptr/\n> \n>> +\tconst char *strtab = NULL;\n>> +\n>> +\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n> \n> Maybe\n> \n> \tfor (const ELFW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n\n\nSure but s/ELFW/ElfW/ ...\n\n> ?\n> \n> Do I understand correctly that _DYNAMIC is the dynamic tags array for\n> the current ELF binary, and thus always corresponds to libcamera.so, not\n> the code calling get_runpath() ? That's what we need, but I think it\n> should be documented.\n> \n>> +\t\tif (dyn->d_tag == DT_STRTAB)\n>> +\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n>> +\t\telse if (dyn->d_tag == DT_RUNPATH)\n>> +\t\t\trunpath = dyn;\n>> +\t}\n>> +\n>> +\tif (strtab && runpath)\n>> +\t\treturn strtab + runpath->d_un.d_val;\n>> +\n>> +\treturn NULL;\n> \n> nullptr here too.\n> \n>> +}\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n>> +\n>>  /**\n>>   * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n>>   *\t\t\t\t     InputIt2 first2, InputIt2 last2)\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 969B56043D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Feb 2020 15:05:56 +0100 (CET)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F0728808;\n\tTue, 11 Feb 2020 15:05:55 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581429956;\n\tbh=+moz4RtTpYCEFWMRxfPc01jK7rdKzy5A36o//Pnx44w=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=uCvjEB8KCIZCGvPy+Q21NloiuEP/5ZJmbLMZrf/rb8tEVIcwapR3snqIBvggybH/X\n\t5QsaMbIVbVQCuBfxXCCl/0tRRooHJgBNhNt499lfK0PXyG4g0We10suciTAYc58dJ/\n\tMeL4UomKqjLy7n4qZr0/fyKnKpqTuX1s+nOD7cdQ=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>\n\t<20200206180738.GA7611@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq\n\t8K8FieAjgjMSxngo/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQcOdhtd36\n\tOe9X9dXB8YSNt7VjOcO7BTmFn/Z8r92mSAfHXpb07YJWJosQOQARAQABtDBLaWVyYW4gQmlu\n\tZ2hhbSA8a2llcmFuLmJpbmdoYW1AaWRlYXNvbmJvYXJkLmNvbT6JAlcEEwEKAEECGwMFCwkI\n\tBwIGFQgJCg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/o7z95frkP71EaICttZ6k9q5oxxA5WC6sTXc\n\tMW8zs8avFNuA9VpXt0YupJd2ijtZy2mpZNG02fFVXhIn4G807G7+9mhuC4XG5rKlBBUXTvPU\n\tAfYnB4JBDLmLzBFavQfvonSfbitgXwCG3vS+9HEwAjU30Bar1PEOmIbiAoMzuKeRm2LVpmq4\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<a66df126-6dca-601b-d163-372373ae7eb0@ideasonboard.com>","Date":"Tue, 11 Feb 2020 14:05:53 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.9.1","MIME-Version":"1.0","In-Reply-To":"<20200206180738.GA7611@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 11 Feb 2020 14:05:56 -0000"}},{"id":3655,"web_url":"https://patchwork.libcamera.org/comment/3655/","msgid":"<20200211155859.GF22612@pendragon.ideasonboard.com>","date":"2020-02-11T15:58:59","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Tue, Feb 11, 2020 at 02:05:53PM +0000, Kieran Bingham wrote:\n> On 06/02/2020 18:07, Laurent Pinchart wrote:\n> > On Wed, Feb 05, 2020 at 01:04:16PM +0000, Kieran Bingham wrote:\n> >> Provide a helper that will identify the DT_RUNPATH string from the\n> >> ELF dynamic library string table entries.\n> >>\n> >> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >> ---\n> >>  src/libcamera/include/utils.h |  1 +\n> >>  src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n> >>  2 files changed, 27 insertions(+)\n> >>\n> >> diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> >> index e467eb21c518..069b327bb436 100644\n> >> --- a/src/libcamera/include/utils.h\n> >> +++ b/src/libcamera/include/utils.h\n> >> @@ -33,6 +33,7 @@ namespace utils {\n> >>  const char *basename(const char *path);\n> >>  \n> >>  char *secure_getenv(const char *name);\n> >> +const char *get_runpath();\n> >>  \n> >>  template<class InputIt1, class InputIt2>\n> >>  unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n> >> diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> >> index 4beffdab5eb6..e48cf2b6a48e 100644\n> >> --- a/src/libcamera/utils.cpp\n> >> +++ b/src/libcamera/utils.cpp\n> >> @@ -7,7 +7,9 @@\n> >>  \n> >>  #include \"utils.h\"\n> >>  \n> >> +#include <elf.h>\n> >>  #include <iomanip>\n> >> +#include <link.h>\n> >>  #include <sstream>\n> >>  #include <stdlib.h>\n> >>  #include <string.h>\n> >> @@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n> >>  #endif\n> >>  }\n> >>  \n> >> +/**\n> >> + * \\brief Obtain the runpath string from the dynamic symbol table\n> > \n> > It's the \"dynamic tags\" (.dynamic), not \"dynamic symbol table\"\n> > (.dynsym).\n> > \n> >> + * \\returns a const char pointer to the runpath entry in the elf string table\n> > \n> > s/returns/return/\n> > \n> > Actually after checking the doxygen documentation \\returns is an alias\n> > for \\return. Still, I think we should standardize on \\return.\n> \n> Looks like I copied \\returns from the secure_getenv above.\n> \n> I'll send a patch to fix that, and the other one in the source code.\n> \n>  <sent>\n> \n> > s/a const/A const/\n> > \n> > Maybe s/elf/ELF/ ?\n> > \n> >> + * or NULL if it is not found.\n> \n> s/NULL/nullptr here of course too\n> \n> Perhaps NULL => nullptr should be in checkstyle.py.\n\nThat's a good idea. It should be easy to add a regex that will match on\nNULL, but ideally we should have a better parser that would handle the\ncontext. \"NULL\" may be acceptable, as well as NULL in a comment for\ninstance.\n\nDoes clang-format support python plugins ? :-)\n\n> > s/\\.$//\n> > \n> >> + */\n> >> +const char *get_runpath()\n> > \n> > We only use this function in a single location, I'm tempted to move it\n> > to ipa_manager.cpp. If we want to create ELF-related helpers, then\n> \n> Indeed, as it's only a single use and not expected to be used elsewhere\n> it could be a local static.\n> \n> At that point, the implementation can be squashed into the patch that\n> needs it too.\n> \n> > moving this, along with the ELF code from ipa_module.cpp to an elf.cpp\n> > file could be useful, but would be overkill for now.\n> \n> If we end up with any more ELF support, I'd like to see it all collected\n> together indeed but for now it's fine.\n> \n> > How about calling it elf_get_runpath(), elf_runpath(), or elfRunPath() ?\n> > The latter is more compliant with our coding style. The reason why most\n> > other functions in this file use snake case instead of camel case is\n> > because they mimic the glibc or libstdc++ APIs.\n> \n> I was mimicking the style of this file.\n> \n> I'll move to ipa_manager and use elfRunPath\n> \n> >> +{\n> >> +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n> >> +\tconst ElfW(Dyn) *runpath = NULL;\n> > \n> > %s/NULL/nullptr/\n> > \n> >> +\tconst char *strtab = NULL;\n> >> +\n> >> +\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n> > \n> > Maybe\n> > \n> > \tfor (const ELFW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n> \n> Sure but s/ELFW/ElfW/ ...\n\nAbsolutely :-)\n\n> > ?\n> > \n> > Do I understand correctly that _DYNAMIC is the dynamic tags array for\n> > the current ELF binary, and thus always corresponds to libcamera.so, not\n> > the code calling get_runpath() ? That's what we need, but I think it\n> > should be documented.\n> > \n> >> +\t\tif (dyn->d_tag == DT_STRTAB)\n> >> +\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n> >> +\t\telse if (dyn->d_tag == DT_RUNPATH)\n> >> +\t\t\trunpath = dyn;\n> >> +\t}\n> >> +\n> >> +\tif (strtab && runpath)\n> >> +\t\treturn strtab + runpath->d_un.d_val;\n> >> +\n> >> +\treturn NULL;\n> > \n> > nullptr here too.\n> > \n> >> +}\n> > \n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > \n> >> +\n> >>  /**\n> >>   * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n> >>   *\t\t\t\t     InputIt2 first2, InputIt2 last2)","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 457496043D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Feb 2020 16:59:14 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A3B452D2;\n\tTue, 11 Feb 2020 16:59:13 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581436753;\n\tbh=3bgUIlWlDwB5680BfGqhhm5yXR3QzIn36ahBU+BEIeM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TpPZFowXzgc1s/Z0Qz2kOvN0Kc0ien/yuGjBJxqvVWGQEzRl5/sMGkz4yG1B5w5jn\n\tW/pN0dUq6catvdObmEgpI+GMWuQ0KKMukEr+YJ0wVE9lSdDEDsjDy3FhfjWmgOMNTK\n\tLOK/1R1TfhBj3cs6rk/wE+09701EqM+7lvalf1gc=","Date":"Tue, 11 Feb 2020 17:58:59 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20200211155859.GF22612@pendragon.ideasonboard.com>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>\n\t<20200206180738.GA7611@pendragon.ideasonboard.com>\n\t<a66df126-6dca-601b-d163-372373ae7eb0@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<a66df126-6dca-601b-d163-372373ae7eb0@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 11 Feb 2020 15:59:14 -0000"}},{"id":3697,"web_url":"https://patchwork.libcamera.org/comment/3697/","msgid":"<bf954de90553472ae6aa3657c25c66af9a173ec9.camel@ndufresne.ca>","date":"2020-02-12T17:44:52","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":30,"url":"https://patchwork.libcamera.org/api/people/30/","name":"Nicolas Dufresne","email":"nicolas@ndufresne.ca"},"content":"Le mardi 11 février 2020 à 17:58 +0200, Laurent Pinchart a écrit :\n> Hi Kieran,\n> \n> On Tue, Feb 11, 2020 at 02:05:53PM +0000, Kieran Bingham wrote:\n> > On 06/02/2020 18:07, Laurent Pinchart wrote:\n> > > On Wed, Feb 05, 2020 at 01:04:16PM +0000, Kieran Bingham wrote:\n> > > > Provide a helper that will identify the DT_RUNPATH string from the\n> > > > ELF dynamic library string table entries.\n> > > > \n> > > > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > > > ---\n> > > >  src/libcamera/include/utils.h |  1 +\n> > > >  src/libcamera/utils.cpp       | 26 ++++++++++++++++++++++++++\n> > > >  2 files changed, 27 insertions(+)\n> > > > \n> > > > diff --git a/src/libcamera/include/utils.h b/src/libcamera/include/utils.h\n> > > > index e467eb21c518..069b327bb436 100644\n> > > > --- a/src/libcamera/include/utils.h\n> > > > +++ b/src/libcamera/include/utils.h\n> > > > @@ -33,6 +33,7 @@ namespace utils {\n> > > >  const char *basename(const char *path);\n> > > >  \n> > > >  char *secure_getenv(const char *name);\n> > > > +const char *get_runpath();\n> > > >  \n> > > >  template<class InputIt1, class InputIt2>\n> > > >  unsigned int set_overlap(InputIt1 first1, InputIt1 last1,\n> > > > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\n> > > > index 4beffdab5eb6..e48cf2b6a48e 100644\n> > > > --- a/src/libcamera/utils.cpp\n> > > > +++ b/src/libcamera/utils.cpp\n> > > > @@ -7,7 +7,9 @@\n> > > >  \n> > > >  #include \"utils.h\"\n> > > >  \n> > > > +#include <elf.h>\n> > > >  #include <iomanip>\n> > > > +#include <link.h>\n> > > >  #include <sstream>\n> > > >  #include <stdlib.h>\n> > > >  #include <string.h>\n> > > > @@ -70,6 +72,30 @@ char *secure_getenv(const char *name)\n> > > >  #endif\n> > > >  }\n> > > >  \n> > > > +/**\n> > > > + * \\brief Obtain the runpath string from the dynamic symbol table\n> > > \n> > > It's the \"dynamic tags\" (.dynamic), not \"dynamic symbol table\"\n> > > (.dynsym).\n> > > \n> > > > + * \\returns a const char pointer to the runpath entry in the elf string table\n> > > \n> > > s/returns/return/\n> > > \n> > > Actually after checking the doxygen documentation \\returns is an alias\n> > > for \\return. Still, I think we should standardize on \\return.\n> > \n> > Looks like I copied \\returns from the secure_getenv above.\n> > \n> > I'll send a patch to fix that, and the other one in the source code.\n> > \n> >  <sent>\n> > \n> > > s/a const/A const/\n> > > \n> > > Maybe s/elf/ELF/ ?\n> > > \n> > > > + * or NULL if it is not found.\n> > \n> > s/NULL/nullptr here of course too\n> > \n> > Perhaps NULL => nullptr should be in checkstyle.py.\n> \n> That's a good idea. It should be easy to add a regex that will match on\n> NULL, but ideally we should have a better parser that would handle the\n> context. \"NULL\" may be acceptable, as well as NULL in a comment for\n> instance.\n> \n> Does clang-format support python plugins ? :-)\n\nThat is good idea since it will be very common from C and specially\nGStreamer contributors. Basically any code that is copied from\nsomewhere else will have NULL in it.\n\n> \n> > > s/\\.$//\n> > > \n> > > > + */\n> > > > +const char *get_runpath()\n> > > \n> > > We only use this function in a single location, I'm tempted to move it\n> > > to ipa_manager.cpp. If we want to create ELF-related helpers, then\n> > \n> > Indeed, as it's only a single use and not expected to be used elsewhere\n> > it could be a local static.\n> > \n> > At that point, the implementation can be squashed into the patch that\n> > needs it too.\n> > \n> > > moving this, along with the ELF code from ipa_module.cpp to an elf.cpp\n> > > file could be useful, but would be overkill for now.\n> > \n> > If we end up with any more ELF support, I'd like to see it all collected\n> > together indeed but for now it's fine.\n> > \n> > > How about calling it elf_get_runpath(), elf_runpath(), or elfRunPath() ?\n> > > The latter is more compliant with our coding style. The reason why most\n> > > other functions in this file use snake case instead of camel case is\n> > > because they mimic the glibc or libstdc++ APIs.\n> > \n> > I was mimicking the style of this file.\n> > \n> > I'll move to ipa_manager and use elfRunPath\n> > \n> > > > +{\n> > > > +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n> > > > +\tconst ElfW(Dyn) *runpath = NULL;\n> > > \n> > > %s/NULL/nullptr/\n> > > \n> > > > +\tconst char *strtab = NULL;\n> > > > +\n> > > > +\tfor (; dyn->d_tag != DT_NULL; ++dyn) {\n> > > \n> > > Maybe\n> > > \n> > > \tfor (const ELFW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n> > \n> > Sure but s/ELFW/ElfW/ ...\n> \n> Absolutely :-)\n> \n> > > ?\n> > > \n> > > Do I understand correctly that _DYNAMIC is the dynamic tags array for\n> > > the current ELF binary, and thus always corresponds to libcamera.so, not\n> > > the code calling get_runpath() ? That's what we need, but I think it\n> > > should be documented.\n> > > \n> > > > +\t\tif (dyn->d_tag == DT_STRTAB)\n> > > > +\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n> > > > +\t\telse if (dyn->d_tag == DT_RUNPATH)\n> > > > +\t\t\trunpath = dyn;\n> > > > +\t}\n> > > > +\n> > > > +\tif (strtab && runpath)\n> > > > +\t\treturn strtab + runpath->d_un.d_val;\n> > > > +\n> > > > +\treturn NULL;\n> > > \n> > > nullptr here too.\n> > > \n> > > > +}\n> > > \n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > \n> > > > +\n> > > >  /**\n> > > >   * \\fn libcamera::utils::set_overlap(InputIt1 first1, InputIt1 last1,\n> > > >   *\t\t\t\t     InputIt2 first2, InputIt2 last2)","headers":{"Return-Path":"<nicolas@ndufresne.ca>","Received":["from mail-qt1-x841.google.com (mail-qt1-x841.google.com\n\t[IPv6:2607:f8b0:4864:20::841])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F69E61917\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Feb 2020 18:44:55 +0100 (CET)","by mail-qt1-x841.google.com with SMTP id r5so2208737qtt.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 12 Feb 2020 09:44:55 -0800 (PST)","from skullcanyon ([192.222.193.21])\n\tby smtp.gmail.com with ESMTPSA id\n\tg26sm588624qkk.68.2020.02.12.09.44.53\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 12 Feb 2020 09:44:53 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ndufresne-ca.20150623.gappssmtp.com; s=20150623;\n\th=message-id:subject:from:to:cc:date:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=ZgNoRFgSHQImSk43rMFwhDHSUHXzgDw7bYKPZjJfEQA=;\n\tb=jIfmvH6Au5h/ajYmmIoj3eaaa+jlz+G836YfSDqtrQs5YV9Z8J5efA27cMYx+0tSiO\n\t63pBRe/wIR6Hnh8pqTvkSin9s/ND8FdupgNUVaDvhMbOSN4RSVtMCeDle57XVG3pEsCT\n\tF5DqzwhYUE05kpLozzLZYWT0or04m9zxmklV1+m94wvPMJJOdVKkhQhFkX2e01aZ5Xrk\n\thLaxk0NAJoaYQ5qII0EH0RTeR7vvtPl+mnCm4eHsKNVHKT8w2Z22QwjCk1FEq18G4TSx\n\trC1yxRTp1CSbYFiAqdKa4Gb/ZRzq5JlSYEiMMR+a+uTWGJ0VROJZaDgLVFguIPSDFbv4\n\tr37Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=ZgNoRFgSHQImSk43rMFwhDHSUHXzgDw7bYKPZjJfEQA=;\n\tb=Bnbhhv7KsTORGUlsnO0AikuIZS+4x0SF3utP10RrTcLUOIoOF9gdBMzONFEhyFwN80\n\tbp+6WijPw9cqNDRfjyN1OFpyZk8xXeVYmN9DXoJMXQDAU1usEK9SqT2+2DEGXnt5217H\n\txMXgoVnbV7RsRF/LEdEr0iqshLLltufPVJRIpm1tLtjxHnwiPIN0hb35xBudWa2d+G4f\n\teCSn2Xvh4/mFxAQpvoO7D/GK8jdaxneX6EO5aB29sZDH8y6A/82vL5oKTQe1Ty5BitAT\n\twiXugy0l9GzWsKD6HEO2KY2P3YEikbP+gRepwqIb9lZzwpNfx/KryEQzKsL8wmHby74u\n\tKcOQ==","X-Gm-Message-State":"APjAAAW/INvNPUtqxHMxX4xXtpIrf2cvQa3jTUryrVQ5NDpL6FYb6KiR\n\taoj6Xyq5DdJR+oUbT7Vu4rfJIg==","X-Google-Smtp-Source":"APXvYqwg/0JfTTqY4LoyK5qXaQRAMcLBwCC9O9rLkSrEkge+sKG74reC6MovBTgeh8nw+Xw/EcGWcA==","X-Received":"by 2002:ac8:176b:: with SMTP id\n\tu40mr20800844qtk.272.1581529494087; \n\tWed, 12 Feb 2020 09:44:54 -0800 (PST)","Message-ID":"<bf954de90553472ae6aa3657c25c66af9a173ec9.camel@ndufresne.ca>","From":"Nicolas Dufresne <nicolas@ndufresne.ca>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>, Kieran Bingham\n\t<kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Date":"Wed, 12 Feb 2020 12:44:52 -0500","In-Reply-To":"<20200211155859.GF22612@pendragon.ideasonboard.com>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>\n\t<20200206180738.GA7611@pendragon.ideasonboard.com>\n\t<a66df126-6dca-601b-d163-372373ae7eb0@ideasonboard.com>\n\t<20200211155859.GF22612@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","User-Agent":"Evolution 3.34.3 (3.34.3-1.fc31) ","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 12 Feb 2020 17:44:55 -0000"}},{"id":3809,"web_url":"https://patchwork.libcamera.org/comment/3809/","msgid":"<fcf28b03-ce17-d4da-759a-7e7fbcba5407@ideasonboard.com>","date":"2020-02-18T17:18:01","subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 06/02/2020 21:03, Laurent Pinchart wrote:\n> Hi Kieran,\n> \n> Another comment.\n> \n\n>>> +{\n>>> +\tconst ElfW(Dyn) *dyn = _DYNAMIC;\n> \n> bionic and musl don't seem to provide _DYNAMIC :-S They both have elf.h\n> and link.h, with a definition of the macros and structures used below,\n> but _DYNAMIC seems to be missing. I may be missing something, it should\n> be tested.\n\nMUSL proved to be a real problem on this topic, so I've started a rework\nto incorporate the path to a dedicated section and we'll have to\nmanually strip that as part of the install phase.\n\n--\nKieran\n\n\n> 42\t\t\t\tstrtab = reinterpret_cast<const char *>(dyn->d_un.d_val);\n> (gdb) n\n> 38\t\tfor (const ElfW(Dyn) *dyn = _DYNAMIC; dyn->d_tag != DT_NULL; ++dyn) {\n> (gdb) p strtab\n> $2 = 0x1560 <error: Cannot access memory at address 0x1560>\n> (gdb) p dyn\n> $3 = (const Elf64_Dyn *) 0x55a12b3bccc8\n> (gdb) p *dyn\n> $4 = {d_tag = 5, d_un = {d_val = 5472, d_ptr = 5472}}","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 77BCF60837\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 18 Feb 2020 18:18:06 +0100 (CET)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D26622F9;\n\tTue, 18 Feb 2020 18:18:05 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1582046286;\n\tbh=J+LBU9yctJgJt5yL1qgYvan1DiU34Q3Or/k/YJFW6tg=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=fq/o7uoIUBikIGlA7ySco6wqlk0z6Pn5D25MffqAbk3jPbWUCKf5WMmouy/VShLxz\n\tqsOr6UY5TLok1NHLB+J3Jd3LY6SMsy7ZIfOlKoB0zaZ2E92A6awkZIk+Z3A3hALWZQ\n\t741Du5pCJ49u6pf2r37tOMKVrd2asNTgUmq6NxCY=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","References":"<20200205130420.8736-1-kieran.bingham@ideasonboard.com>\n\t<20200205130420.8736-2-kieran.bingham@ideasonboard.com>\n\t<20200206180738.GA7611@pendragon.ideasonboard.com>\n\t<20200206210348.GA21834@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","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01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<fcf28b03-ce17-d4da-759a-7e7fbcba5407@ideasonboard.com>","Date":"Tue, 18 Feb 2020 17:18:01 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.9.1","MIME-Version":"1.0","In-Reply-To":"<20200206210348.GA21834@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 1/5] libcamera: utils: Provide helper\n\tto get dynamic library runpath","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Tue, 18 Feb 2020 17:18:06 -0000"}}]