From: Lars M. <lar...@te...> - 2014-09-28 23:55:33
|
Hello at all, I'm working a lot with nasm and after a while I created a little library I use in all nasm-Projects. Therefor some header files are very useful (e.g. defining constants and externs). I don't want to mess around with some macros for simple imports. I thought of a c-prototype-like symbol definition for externs. What if a defined extern could be redefined as global. I had a look at the source code and found two possible solutions: 1.) see http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l278 one could allow in line 294, that externs could be redefined as global. By a quick look, I think, that this wouldn't be a problem for the labelmanager. find_lable simply returns the label and define_lable would refill it with the global singal data. The bigger problem is the ofmt, because the ofmt->symdef is explicitly called _once_ for each symbol. Looking at, for example, the objobj.c you can see, that symbols are stored in linked lists and there is no check for double names or something like that. -> Bad solution (update all objformats, looping through list for each symbol) 2.) if somehow possible, and symbols do not need to passed to the ofmt directly after they were found (somehow context dependend), then you could buffer the extern symbols until the whole analysis is ready. every extern symbol that was not replaced by a global would then be passed the the ofmt. exclude extern symbols at http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l327 and introduce a new function, that loops through all symbols and passes the missing externs to the ofmt. call the function in the main function at the right place (maybe here: http://repo.or.cz/w/nasm.git/blob/HEAD:/nasm.c#l466). I would love to from you! Lars |
From: suresh b. <k_s...@ya...> - 2014-10-02 04:57:46
|
Hi Lars, If an extern is used in any program, it mean that the defined variable / label / name is globally defined. Then why again making it a gloabl? You said in your old mails that you are making a single library for all exe formats. Can you give your objective of modifying the nasm and its purpose before we understand the code you are referring here. DEVELOPING AN OPTIONs WINDOW FOR NASM ======================================= I am interested to develop a simple window with options set through a menu to run nasm. In the command line we give options but instead we can give them through a menu and save the options file similar to a project file in build systems. Looking for suggestions and comments for my initiative. regards, sureshbk. On Monday, September 29, 2014 5:25 AM, Lars Maier <lar...@te...> wrote: Hello at all, I'm working a lot with nasm and after a while I created a little library I use in all nasm-Projects. Therefor some header files are very useful (e.g. defining constants and externs). I don't want to mess around with some macros for simple imports. I thought of a c-prototype-like symbol definition for externs. What if a defined extern could be redefined as global. I had a look at the source code and found two possible solutions: 1.) see http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l278 one could allow in line 294, that externs could be redefined as global. By a quick look, I think, that this wouldn't be a problem for the labelmanager. find_lable simply returns the label and define_lable would refill it with the global singal data. The bigger problem is the ofmt, because the ofmt->symdef is explicitly called _once_ for each symbol. Looking at, for example, the objobj.c you can see, that symbols are stored in linked lists and there is no check for double names or something like that. -> Bad solution (update all objformats, looping through list for each symbol) 2.) if somehow possible, and symbols do not need to passed to the ofmt directly after they were found (somehow context dependend), then you could buffer the extern symbols until the whole analysis is ready. every extern symbol that was not replaced by a global would then be passed the the ofmt. exclude extern symbols at http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l327 and introduce a new function, that loops through all symbols and passes the missing externs to the ofmt. call the function in the main function at the right place (maybe here: http://repo.or.cz/w/nasm.git/blob/HEAD:/nasm.c#l466). I would love to from you! Lars ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Nasm-devel mailing list Nas...@li... https://lists.sourceforge.net/lists/listinfo/nasm-devel |
From: H. P. A. <hp...@zy...> - 2014-10-02 15:31:43
|
On 09/28/2014 04:39 PM, Lars Maier wrote: > Hello at all, > I'm working a lot with nasm and after a while I created a little library > I use in all nasm-Projects. Therefor some header files are very useful > (e.g. defining constants and externs). > I don't want to mess around with some macros for simple imports. I > thought of a c-prototype-like symbol definition for externs. What if a > defined extern could be redefined as global. > > I had a look at the source code and found two possible solutions: > > 1.) see http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l278 > one could allow in line 294, that externs could be redefined as global. > By a quick look, I think, that this wouldn't be a problem for the > labelmanager. find_lable simply returns the label and define_lable would > refill it with the global singal data. The bigger problem is the ofmt, > because the ofmt->symdef is explicitly called _once_ for each symbol. > Looking at, for example, the objobj.c you can see, that symbols are > stored in linked lists and there is no check for double names or > something like that. -> Bad solution (update all objformats, looping > through list for each symbol) > > 2.) if somehow possible, and symbols do not need to passed to the ofmt > directly after they were found (somehow context dependend), then you > could buffer the extern symbols until the whole analysis is ready. every > extern symbol that was not replaced by a global would then be passed the > the ofmt. exclude extern symbols at > http://repo.or.cz/w/nasm.git/blob/HEAD:/labels.c#l327 and introduce a > new function, that loops through all symbols and passes the missing > externs to the ofmt. call the function in the main function at the right > place (maybe here: http://repo.or.cz/w/nasm.git/blob/HEAD:/nasm.c#l466). > > I would love to from you! > Lars > It would seem like a reasonable thing to do, and is obviously use in C to good effect. I agree that option 2 would by far be preferable, and it looks like you have thought of this a lot. Would you be willing to write up a patch? -hpa |
From: Lars M. <lar...@te...> - 2014-10-03 11:16:45
|
Hi, Am 02.10.2014 um 22:02 schrieb Cyrill Gorcunov: > Hi Lars, sorry for delays! I'll reply hopefully on weekend once > I get more free time. That said the email is seen and not lost. I didn't expect any answer since I saw the date of the last activity. :D Am 02.10.2014 um 06:54 schrieb suresh babu: > If an extern is used in any program, it mean that the defined variable > / label / name is globally defined. Then why again making it a gloabl? > You mean like MASM's EXTERNDEF? > > http://msdn.microsoft.com/en-us/library/91sxd44w.aspx To make it clear, here is an example: myfunc.inc: %define MY_FUNC_FLAG_A 0x0001 %define MY_FUNC_FLAG_B 0x0002 [...] ; myfunc(param1, param2) : result ; this function does something and returns a value of it [extern myfunc] myfunc.asm: %include 'include/myfunc.inc' [global myfunc] section .code myfunc: push ebp mov ebp, esp mov eax, [ebp+0x08] test eax, MY_FUNC_FLAG_A jnz .flagA [...] otherfile.asm %include 'include/myfunc.inc' section .code push 0 push MY_FUNC_FLAG_A call myfunc Am 02.10.2014 um 17:31 schrieb H. Peter Anvin: > Would you be willing to > write up a patch? I dont have much time in the next few weeks because university starts again, but I'll do my best to find time and implement this feature, if wanted. It would be great if you could support me if there are any questions. |
From: Lars M. <lar...@te...> - 2014-10-04 20:35:19
|
Hi, today and yesterday I worked a bit at the feature we previously talked about. This is not as easy as it might seems to be. It took very long for me to understand the programm mechanics. Now I'm at the following point: I can record extern definitions and prevent nasm from passing them to the ofmt. Although a redefinition as global is possible and they were treated as "unseen" labels. So the old function of a global label still works. There is just one problem: when passing the recorded extern labels, exept those wich are globals now, after the assembling is done, then the reloc adresses are broken in the output file. I guess this is because while assembling nasm is unable to resolve the label references. I would fix this, but I have no idea where and when this resolving takes places? Just to make the problem clearer: nasm -f elf test\externdef.asm [extern externFunc] [extern externFunc2] [extern myFunc] [global myFunc] [section .text use32 class=code] ; just some senseless code to create references and relocs myFunc: push ebp mov ebp, esp .local: mov eax, 0x01 jmp .local leave ret 4 abc: call [externFunc] call [externFunc2] call [myFunc] ret 4 objdump -x test\externdef.o nasm-2.11.05\test\externdef.o: file format elf32-i386 nasm-2.11.05\test\externdef.o architecture: i386, flags 0x00000011: HAS_RELOC, HAS_SYMS start address 0x00000000 Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000023 00000000 00000000 00000130 2**4 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE SYMBOL TABLE: 00000000 l df *ABS* 00000000 test\externdef.asm 00000000 l d .text 00000000 .text 00000003 l .text 00000000 myFunc.local 0000000e l .text 00000000 abc 00000000 *UND* 00000000 externFunc 00000000 *UND* 00000000 externFunc2 00000000 g .text 00000000 myFunc RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 00000010 R_386_32 myFunc 00000016 R_386_32 myFunc 0000001c R_386_32 myFunc |
From: anonymous c. <nas...@us...> - 2014-10-12 02:47:44
|
>> You mean like MASM's EXTERNDEF? >> >> http://msdn.microsoft.com/en-us/library/91sxd44w.aspx > > To make it clear, here is an example: > > myfunc.inc: > > %define MY_FUNC_FLAG_A 0x0001 > %define MY_FUNC_FLAG_B 0x0002 > [...] > > ; myfunc(param1, param2) : result > ; this function does something and returns a value of it > [extern myfunc] > > > myfunc.asm: > %include 'include/myfunc.inc' > [global myfunc] > > section .code > > myfunc: > push ebp > mov ebp, esp > mov eax, [ebp+0x08] > test eax, MY_FUNC_FLAG_A > jnz .flagA > [...] > > > otherfile.asm > %include 'include/myfunc.inc' > > section .code > > push 0 > push MY_FUNC_FLAG_A > call myfunc Yup, that's the EXTERNDEF behavior. You should called it that. |
From: suresh b. <k_s...@ya...> - 2014-10-13 00:06:39
|
Yes right exactly and thanks for more clear clarification. On Sunday, October 12, 2014 8:17 AM, anonymous coward <nas...@us...> wrote: >> You mean like MASM's EXTERNDEF? >> >> http://msdn.microsoft.com/en-us/library/91sxd44w.aspx > > To make it clear, here is an example: > > myfunc.inc: > > %define MY_FUNC_FLAG_A 0x0001 > %define MY_FUNC_FLAG_B 0x0002 > [...] > > ; myfunc(param1, param2) : result > ; this function does something and returns a value of it > [extern myfunc] > > > myfunc.asm: > %include 'include/myfunc.inc' > [global myfunc] > > section .code > > myfunc: > push ebp > mov ebp, esp > mov eax, [ebp+0x08] > test eax, MY_FUNC_FLAG_A > jnz .flagA > [...] > > > otherfile.asm > %include 'include/myfunc.inc' > > section .code > > push 0 > push MY_FUNC_FLAG_A > call myfunc Yup, that's the EXTERNDEF behavior. You should called it that. ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://p.sf.net/sfu/Zoho _______________________________________________ Nasm-devel mailing list Nas...@li... https://lists.sourceforge.net/lists/listinfo/nasm-devel |
From: Lars M. <lar...@te...> - 2014-10-18 11:16:23
|
Okay. So why we don't just introduce externdef as keyword? This would be less work, than caching the extern definitions and wait for their redefinition. Am 13.10.2014 um 02:03 schrieb suresh babu: > Yes right exactly and thanks for more clear clarification. > > > On Sunday, October 12, 2014 8:17 AM, anonymous coward > <nas...@us...> wrote: > > > >> You mean like MASM's EXTERNDEF? > >> > >> http://msdn.microsoft.com/en-us/library/91sxd44w.aspx > > > > To make it clear, here is an example: > > > > myfunc.inc: > > > > %define MY_FUNC_FLAG_A 0x0001 > > %define MY_FUNC_FLAG_B 0x0002 > > [...] > > > > ; myfunc(param1, param2) : result > > ; this function does something and returns a value of it > > [extern myfunc] > > > > > > myfunc.asm: > > %include 'include/myfunc.inc' > > [global myfunc] > > > > section .code > > > > myfunc: > > push ebp > > mov ebp, esp > > mov eax, [ebp+0x08] > > test eax, MY_FUNC_FLAG_A > > jnz .flagA > > [...] > > > > > > otherfile.asm > > %include 'include/myfunc.inc' > > > > section .code > > > > push 0 > > push MY_FUNC_FLAG_A > > call myfunc > > Yup, that's the EXTERNDEF behavior. > > You should called it that. > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://p.sf.net/sfu/Zoho > _______________________________________________ > Nasm-devel mailing list > Nas...@li... <mailto:Nas...@li...> > https://lists.sourceforge.net/lists/listinfo/nasm-devel > > > > > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://p.sf.net/sfu/Zoho > > > _______________________________________________ > Nasm-devel mailing list > Nas...@li... > https://lists.sourceforge.net/lists/listinfo/nasm-devel |
From: suresh b. <k_s...@ya...> - 2014-10-18 14:23:54
|
Hi Lars, We can do it. externdef as a user-level directive for the extern primitive directive. regards, sureshbk. On Saturday, October 18, 2014 4:46 PM, Lars Maier <lar...@te...> wrote: Okay. So why we don't just introduce externdef as keyword? This would be less work, than caching the extern definitions and wait for their redefinition. Am 13.10.2014 um 02:03 schrieb suresh babu: Yes right exactly and thanks for more clear clarification. > > > > >On Sunday, October 12, 2014 8:17 AM, anonymous coward <nas...@us...> wrote: > > > >>> You mean like MASM's EXTERNDEF? >>> >>> http://msdn.microsoft.com/en-us/library/91sxd44w.aspx >> >> To make it clear, here is an example: >> >> myfunc.inc: >> >> %define MY_FUNC_FLAG_A 0x0001 >> %define MY_FUNC_FLAG_B 0x0002 >> [...] >> >> ; myfunc(param1, param2) : result >> ; this function does something and returns a value of it >> [extern myfunc] >> >> >> myfunc.asm: >> %include 'include/myfunc.inc' >> [global myfunc] >> >> section .code >> >> myfunc: >> push ebp >> mov ebp, esp >> mov eax, [ebp+0x08] >> test eax, MY_FUNC_FLAG_A >> jnz .flagA >> [...] >> >> >> otherfile.asm >> %include 'include/myfunc.inc' >> >> section .code >> >> push 0 >> push MY_FUNC_FLAG_A >> call myfunc > >Yup, that's the EXTERNDEF behavior. > >You should called it that. > >------------------------------------------------------------------------------ >Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer >Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports >Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper >Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer >http://p.sf.net/sfu/Zoho >_______________________________________________ >Nasm-devel mailing list >Nas...@li... >https://lists.sourceforge.net/lists/listinfo/nasm-devel > > > > > >------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://p.sf.net/sfu/Zoho > > >_______________________________________________ Nasm-devel mailing list Nas...@li... https://lists.sourceforge.net/lists/listinfo/nasm-devel |
From: Cyrill G. <gor...@gm...> - 2014-10-02 20:02:09
|
On Mon, Sep 29, 2014 at 01:39:51AM +0200, Lars Maier wrote: ... > > I would love to from you! Hi Lars, sorry for delays! I'll reply hopefully on weekend once I get more free time. That said the email is seen and not lost. |
From: anonymous c. <nas...@us...> - 2014-10-02 23:11:49
|
> What if a defined extern could be redefined as global. You mean like MASM's EXTERNDEF? http://msdn.microsoft.com/en-us/library/91sxd44w.aspx |