Hi All, I have created a minimally functional Win32 COFF Exporter using the new MC framework. I made some minor changes to other libraries to allow me to plug it in without building it as part of the LLVM project. I wanted to share it but wasn't sure how to go about doing so, so I have attached the code to this message. Any feedback on would be appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100501/2290f5c7/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: core-changes.patch Type: application/octet-stream Size: 9274 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100501/2290f5c7/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: COFF.7z Type: application/octet-stream Size: 5937 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100501/2290f5c7/attachment-0001.obj>
On 2 May 2010 00:59, Nathan Jeffords <blunted2night at gmail.com> wrote:> Hi All, > > I have created a minimally functional Win32 COFF Exporter using the new MC > framework. I made some minor changes to other libraries to allow me to plug > it in without building it as part of the LLVM project. I wanted to share it > but wasn't sure how to go about doing so, so I have attached the code to > this message. > > Any feedback on would be appreciated. >Hi Nathan, A couple of points :- 1) Your code seems incomplete, there is nothing envoking 'createWin32CoffStreamer()' in you patch. 2) You need to look at LLVM coding standards, i.e. maximum line length of 80 characters and tabs of 2. You need to look at the following document and existing code. Usage of spaces is quite strict. http://llvm.org/docs/CodingStandards.html I too have been working on a COFFWriter but with little success. Got a basic COFFWriter working but have had problems with the MC framework in regards to getting the right information to generate code properly. It will be good if we can get something working first, so send me a proper change set, read this :- http://llvm.org/docs/DeveloperPolicy.html I generally use :- utils/mkpatch patchname from the root svn directory with out the '.patch' to make patches. You need to include any files from 'svn status' with question marks, by doing an 'svn add filename'. Thanks for submitting a patch, most patches are welcomed, but they may need to be honed a bit. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100502/f52bd776/attachment.html>
Hello, Nathan First of all, I would like to mention that COFF MC backend will be a really good contribution to LLVM!> I have created a minimally functional Win32 COFF Exporter using the new MC > framework. I made some minor changes to other libraries to allow me to plug > it in without building it as part of the LLVM project. I wanted to share it > but wasn't sure how to go about doing so, so I have attached the code to > this message. > Any feedback on would beĀ appreciated.As it was already mentioned before you should definitely read & follow LLVM coding standards. I'll let others comment on MC hooks, I just made a very brief look over the contents of the archive. You can find the comments below. First of all, please include all the files as attachments. If you decide to put stuff into archive use something standard, e.g. .zip or .tar.gz. coff.h: Please document the source of the information for this file - some documents, links will be really good. If you copied stuff out of somewhere - there should be some license disclaimer, etc.> #pragma onceUse standard include guards> typedef unsigned char uint8; > typedef unsigned short uint16; > typedef unsigned long uint32;Do not reinvent the wheel - use standard portable types e.g. uint8_t and friends. "unsigned long" is not 32 bit everywhere.> #pragma pack (push, 1)Do not use these pragma's. Not all compilers support them.> struct symbolCould you please add the comments describing the entities involved?> typedef std::map <std::string, size_t> map;Please read http://llvm.org/docs/ProgrammersManual.html and use the data structures already provided by LLVM. E.g. http://llvm.org/docs/ProgrammersManual.html#dss_stringmap should definitely be used here.> #ifdef _MSC_VER > #include "stdafx.h" > #endif > #define report_fatal_error_dbg(x) __debugbreak ()Generally it's prohibited to use target/compiler-specific defines outside of libSystem.> struct MCWin32CoffObjectWriter : > MCObjectWriter, > coff::fileAny reason for such inheritance?> MCSectionCOFF const & Section = dynamic_cast <MCSectionCOFF const &> (SectionData.getSection ());LLVM normally compiles w/o RTTI, so this won't work> CoffSection->Header.Characteristics |> coff::IMAGE_SCN_CNT_CODE | > coff::IMAGE_SCN_MEM_READ | > coff::IMAGE_SCN_MEM_EXECUTE | > false;Was "| false" intentional? Why?> default: > report_fatal_error_dbg ("unsupported section alignment");Use llvm_unreachable()> for (SmallVector<char, Len>::const_iterator i = Data.begin (); i != Data.end (); i++) > { > if (i != Data.begin ()) > dbgout (' ');See llvm/Support/Debug.h for standard way of doing debug output in LLVM code. There are bunch of examples in many places. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
On 2 May 2010 10:53, Anton Korobeynikov <anton at korobeynikov.info> wrote:> Hello, Nathan > I'll let others comment on MC hooks, I just made a very brief look > over the contents of the archive. You can find the comments below. >Yes I looked at this and there are several ways but TargetAsmBackend looked the bast place to deal with the MCStreamer choice for different TargetTriples.> for (SmallVector<char, Len>::const_iterator i > Data.begin (); i != Data.end (); i++) > > { > > if (i != Data.begin ()) > > dbgout (' '); > See llvm/Support/Debug.h for standard way of doing debug output in > LLVM code. There are bunch of examples in many places.See :- http://llvm.org/docs/ProgrammersManual.html#DEBUG Also trailing commas on enums cause errors on GCC. There are more errors on GCC as well which I will forward you ASAIC. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100502/769a0999/attachment.html>
Hi All, After a week of working with several people on this forum, I have a much more functional version of my Win32 COFF object file support. I believe this should cover most use cases. Attached is a patch file against r103336. Feedback is welcome. Thanks, Nathan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100508/e2d91ca0/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: changes.patch Type: application/octet-stream Size: 64936 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100508/e2d91ca0/attachment.obj>